Sage-Bionetworks / sage-monorepo

Where OpenChallenges, Schematic, and other Sage open source apps are built
https://sage-bionetworks.github.io/sage-monorepo/
Apache License 2.0
21 stars 12 forks source link

[Bug] Set the platform to `NULL` for challenge that don't use a registered platform #2385

Closed tschaffter closed 8 months ago

tschaffter commented 9 months ago

Is there an existing issue for this?

What product(s) are you seeing the problem on?

OpenChallenges

Current behavior

The OC Data sheet registers a platform named "other". A first issue is that counting the platforms from the list of challenge platform returns currently 14 while we technically capture information only about 13 platforms. Other issues may arise as we plan to create a challenge platform search page.

Instead, we should no longer create a platform for "other" and set the property challenge.platform to null / undefined when no known challenge platform is used by the challenge. This approach implies changes at the following levels:

  1. [x] OC Data sheet (@vpchung )
  2. [x] OC data model (SQL) (@vpchung )
  3. [x] OC API model (openchallenges-api-description) (@rrchai )
  4. [ ] Challenge service (@tschaffter )
  5. [ ] Web app (@rrchai )

The above tasks should be performed in this order, and this will be reflected on the person assigned to this ticket. Let's try to do everything in a single feature PR that Verena will create as the first contributor to keep thing simple.

Cc: @vpchung @rrchai

Expected behavior

No response

Anything else?

No response

Commit ID

No response

Are you developing inside the dev container?

Code of Conduct

vpchung commented 9 months ago

PR started in #2393.

🏀 passing it to you now, @rrchai !

rrchai commented 9 months ago

The update for API description has been added to #2393

🏀 passing it to you now, @tschaffter ~

tschaffter commented 8 months ago

Option 1: Removing challenge.platform for required challenge properties

When the platform property is required:

  @NotNull
  @Valid
  @Schema(name = "platform", required = true)
  public SimpleChallengePlatformDto getPlatform() {
    return platform;
  }

When the platform property is not required:

  @Valid
  @Schema(name = "platform", required = false)
  public SimpleChallengePlatformDto getPlatform() {
    return platform;
  }

In both case, the current property value returned is (could be changed in the mapper):

  "platform": {
    "id": null,
    "slug": null,
    "name": null
  },

Adding nullable: true to SimpleChallengePlatform does not affect the DTO object.

Option 2: Making challenge.platform nullable

TODO

tschaffter commented 8 months ago

A DTO object freshly created comes with falsy values.

challenge dto initial: class ChallengeDto {
    id: null
    slug: null
    name: null
    headline: null
    description: null
    doi: null
    status: null
    difficulty: null
    platform: null
    websiteUrl: null
    avatarUrl: null
    incentives: []
    submissionTypes: []
    inputDataTypes: null
    startDate: null
    endDate: null
    starredCount: 0
    createdAt: null
    updatedAt: null
}

Consider removing the properties that should not be returned.

tschaffter commented 8 months ago

nullable is replaced by null type in OpenAPI 3.1

Note we are still using OpenAPI 3.0.3

See https://www.openapis.org/blog/2021/02/16/migrating-from-openapi-3-0-to-3-1-0