Skip to content

Commit

Permalink
fix(openchallenges): remove usage of "Other" for platform (#2393)
Browse files Browse the repository at this point in the history
* remove "Other" from list of platforms

* update platforms annotation in db

* restrict the options of challenge platforms

* bbuild updated platform schemas

* make platform nullable

* remove plat enum values

* Marking challenge.platform as nullable in controller

* Run OA generator (wip)

* Update platform mapper (WIP)

* Add log messages (WIP)

* Make `challenge.platform` nullable and optional

* Fix grey style for platform

* Simplify grey-color check

---------

Co-authored-by: Rongrong Chai <[email protected]>
Co-authored-by: Thomas Schaffter <[email protected]>
  • Loading branch information
3 people authored Dec 14, 2023
1 parent 333301e commit 94c12dd
Show file tree
Hide file tree
Showing 18 changed files with 118 additions and 109 deletions.
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"editor.tabSize": 2,
"editor.formatOnSave": false,
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
"source.fixAll.eslint": "explicit"
},
"black-formatter.importStrategy": "fromEnvironment",
"[python]": {
Expand Down
2 changes: 1 addition & 1 deletion apps/openchallenges/challenge-service/requests.http
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ GET {{basePath}}/challengeInputDataTypes?searchTerms=genomic

### Get the challenge with ID 1.

GET {{basePath}}/challenges/1
GET {{basePath}}/challenges/67

### Get the contributions to the challenge with ID 1.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public class ChallengeDto {
private ChallengeDifficultyDto difficulty;

@JsonProperty("platform")
private SimpleChallengePlatformDto platform;
private SimpleChallengePlatformDto platform = null;

@JsonProperty("websiteUrl")
private String websiteUrl;
Expand Down Expand Up @@ -276,9 +276,8 @@ public ChallengeDto platform(SimpleChallengePlatformDto platform) {
*
* @return platform
*/
@NotNull
@Valid
@Schema(name = "platform", required = true)
@Schema(name = "platform", required = false)
public SimpleChallengePlatformDto getPlatform() {
return platform;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public class ChallengeEntity {
private String difficulty;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "platform_id", nullable = false)
@JoinColumn(name = "platform_id", nullable = true)
@IndexedEmbedded(includePaths = {"slug", "name"})
@IndexingDependency(reindexOnUpdate = ReindexOnUpdate.SHALLOW)
private SimpleChallengePlatformEntity platform;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,14 @@
import org.sagebionetworks.openchallenges.challenge.service.model.dto.ChallengeSubmissionTypeDto;
import org.sagebionetworks.openchallenges.challenge.service.model.entity.ChallengeEntity;
import org.sagebionetworks.util.model.mapper.BaseMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;

public class ChallengeMapper extends BaseMapper<ChallengeEntity, ChallengeDto> {

private static final Logger LOG = LoggerFactory.getLogger(ChallengeMapper.class);

private SimpleChallengePlatformMapper platformMapper = new SimpleChallengePlatformMapper();
private SimpleChallengeInputDataTypeMapper inputDataTypeMapper =
new SimpleChallengeInputDataTypeMapper();
Expand All @@ -27,11 +31,15 @@ public ChallengeEntity convertToEntity(ChallengeDto dto, Object... args) {
@Override
public ChallengeDto convertToDto(ChallengeEntity entity, Object... args) {
ChallengeDto dto = new ChallengeDto();
LOG.info("challenge dto initial: {}", dto);
if (entity != null) {
BeanUtils.copyProperties(entity, dto, "stars", "inputDataTypes");
BeanUtils.copyProperties(entity, dto, "stars", "inputDataTypes", "platform");
LOG.info("challenge dto before set: {}", dto);
dto.setStatus(ChallengeStatusDto.fromValue(entity.getStatus()));
dto.setDifficulty(ChallengeDifficultyDto.fromValue(entity.getDifficulty()));
dto.setPlatform(platformMapper.convertToDto(entity.getPlatform()));
// if (entity.getPlatform() != null) {
// dto.setPlatform(platformMapper.convertToDto(entity.getPlatform()));
// }
dto.submissionTypes(
entity.getSubmissionTypes().stream()
.map(o -> ChallengeSubmissionTypeDto.fromValue(o.getName()))
Expand All @@ -42,6 +50,7 @@ public ChallengeDto convertToDto(ChallengeEntity entity, Object... args) {
.toList());
dto.inputDataTypes(inputDataTypeMapper.convertToDtoList(entity.getInputDataTypes()));
dto.starredCount(entity.getStars().size());
LOG.info("challenge dto: {}", dto);
}
return dto;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ public ChallengeDto getChallenge(Long challengeId) {
() ->
new ChallengeNotFoundException(
String.format("The challenge with ID %d does not exist.", challengeId)));
log.info("challenge entity platform: {}", challengeEntity.getPlatform());
ChallengeDto challenge = challengeMapper.convertToDto(challengeEntity);
return challenge;
}
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@
"9","codalab","CodaLab","logo/codalab.jpg","https://codalab.lisn.upsaclay.fr/","2023-08-09 23:01:32","2023-10-19 21:50:30"
"10","codabench","CodaBench","logo/codalab.jpg","https://www.codabench.org/","2023-08-09 23:01:32","2023-10-19 21:50:30"
"13","eterna","Eterna","logo/eterna.svg","https://eternagame.org/","2023-08-09 23:01:32","2023-10-19 21:50:33"
"14","other","Other","","","2023-08-09 23:01:32","2023-10-19 21:50:34"
"15","nightingale-os","Nightingale OS","logo/nightingale-os.jpeg","https://app.nightingalescience.org/","2023-08-22 15:58:49","2023-10-19 21:50:35"
"16","evalai","EvalAI","logo/evalai.png","https://eval.ai/","2023-09-15 16:00:34","2023-10-19 21:50:36"
"17","cache","CACHE","logo/cache.png","https://cache-challenge.org/","2023-10-16 18:43:36","2023-10-25 19:47:54"
"18","cameo","CAMEO","logo/cameo.png","https://www.cameo3d.org","2023-11-13 22:47:03","2023-11-20 21:10:37"
"19","drivendata","DrivenData","logo/drivendata.jpg","https://www.drivendata.org/","2023-11-16 21:57:43","2023-11-20 21:11:32"
"14","nightingale-os","Nightingale OS","logo/nightingale-os.jpeg","https://app.nightingalescience.org/","2023-08-22 15:58:49","2023-12-06 01:10:23"
"15","evalai","EvalAI","logo/evalai.png","https://eval.ai/","2023-09-15 16:00:34","2023-12-06 01:09:55"
"16","cache","CACHE","logo/cache.png","https://cache-challenge.org/","2023-10-16 18:43:36","2023-12-06 01:09:56"
"17","cameo","CAMEO","logo/cameo.png","https://www.cameo3d.org","2023-11-13 22:47:03","2023-12-06 01:09:56"
"18","drivendata","DrivenData","logo/drivendata.jpg","https://www.drivendata.org/","2023-11-16 21:57:43","2023-12-06 01:09:57"
Original file line number Diff line number Diff line change
Expand Up @@ -597,6 +597,7 @@ components:
name: name
id: 1
slug: example-challenge-platform
nullable: true
properties:
id:
description: The unique identifier of a challenge platform.
Expand Down Expand Up @@ -799,7 +800,6 @@ components:
- id
- incentives
- name
- platform
- slug
- starredCount
- status
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,5 @@ pom.xml
README.md
**/application.properties
**/model/dto/*AllOf*.java
**/OpenApiGeneratorApplication.java
**/OpenApiGeneratorApplication.java
**/OpenApiGeneratorApplicationTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,3 @@ src/main/java/org/sagebionetworks/openchallenges/organization/service/model/dto/
src/main/java/org/sagebionetworks/openchallenges/organization/service/model/dto/OrganizationsPageDto.java
src/main/java/org/sagebionetworks/openchallenges/organization/service/model/dto/PageMetadataDto.java
src/main/resources/openapi.yaml
src/test/java/org/sagebionetworks/openchallenges/organization/service/OpenApiGeneratorApplicationTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export interface Challenge {
doi?: string;
status: ChallengeStatus;
difficulty: ChallengeDifficulty;
platform: SimpleChallengePlatform;
platform?: SimpleChallengePlatform | null;
websiteUrl?: string;
avatarUrl?: string;
incentives: Array<ChallengeIncentive>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,7 @@ components:
- id
- slug
- name
nullable: true
ChallengeInputDataTypeId:
description: The unique identifier of a challenge input data type.
type: integer
Expand Down Expand Up @@ -520,7 +521,6 @@ components:
- description
- status
- difficulty
- platform
- incentives
- submissionTypes
- starredCount
Expand Down
2 changes: 1 addition & 1 deletion libs/openchallenges/api-description/build/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,7 @@ components:
- id
- slug
- name
nullable: true
ChallengeInputDataTypeId:
description: The unique identifier of a challenge input data type.
type: integer
Expand Down Expand Up @@ -672,7 +673,6 @@ components:
- description
- status
- difficulty
- platform
- incentives
- submissionTypes
- starredCount
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ required:
- description
- status
- difficulty
- platform
- incentives
- submissionTypes
- starredCount
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ required:
- id
- slug
- name
nullable: true
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ <h3 class="section-title">Challenge Details</h3>
</tr>
<tr>
<td class="text-right">Platform</td>
<td [ngClass]="{ 'text-grey': challenge.platform.name === '' }">
{{ useNaIfFalsey(challenge.platform.name) }}
<td [ngClass]="{ 'text-grey': !challenge.platform }">
{{ useNaIfFalsey(challenge.platform?.name) }}
</td>
</tr>
<tr>
Expand All @@ -51,7 +51,9 @@ <h3 class="section-title">Challenge Details</h3>
</tr>
<tr>
<td class="text-right">Submission Type</td>
<td *ngIf="challenge.inputDataTypes && challenge.submissionTypes.length > 0; else na_subs">
<td
*ngIf="challenge.inputDataTypes && challenge.submissionTypes.length > 0; else na_subs"
>
<span
nowrap
*ngFor="let submissionType of challenge.submissionTypes; let isLast = last"
Expand Down Expand Up @@ -107,6 +109,7 @@ <h3 class="section-title">Hosted By</h3>
href="https://docs.google.com/forms/d/e/1FAIpQLSdkgAVOuof-tE4PvCnpPbbGnQvvMhLuTkXikDXTbsCHqcMVSw/viewform?usp=pp_url&entry.2102238281={{
challenge.id
}}&entry.1040159972={{ challenge.slug }}"
rel="noopener"
target="_blank"
>Suggest an edit here!</a
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,9 @@ <h3>{{ shorthand(mockStargazers) }}</h3>
<a
class="stat-item action-btn"
*ngSwitchCase="true"
href="{{ challenge.websiteUrl }}"
[href]="challenge.websiteUrl"
target="_blank"
title="Go to challenge page on {{
challenge.platform.name === 'Other' ? 'platform' : challenge.platform.name
}}"
title="Go to Website"
rel="noopener noreferrer"
>
<mat-icon aria-hidden="true" class="stats-card-icon">open_in_new</mat-icon>
Expand Down

0 comments on commit 94c12dd

Please sign in to comment.