Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(openchallenges): add caption showing undatedChallengeCounts in timeline plot #2353

Merged
merged 14 commits into from
Nov 16, 2023
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ default ResponseEntity<ChallengesPerYearDto> getChallengesPerYear() {
for (MediaType mediaType : MediaType.parseMediaTypes(request.getHeader("Accept"))) {
if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) {
String exampleString =
"{ \"challengeCounts\" : [ 0, 0 ], \"years\" : [ \"years\", \"years\" ] }";
"{ \"undatedChallengeCount\" : 0, \"challengeCounts\" : [ 0, 0 ], \"years\" : [ \"years\", \"years\" ] }";
ApiUtil.setExampleResponse(request, "application/json", exampleString);
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ public class ChallengesPerYearDto {
@Valid
private List<Integer> challengeCounts = new ArrayList<>();

@JsonProperty("undatedChallengeCount")
private Integer undatedChallengeCount = 0;

public ChallengesPerYearDto years(List<String> years) {
this.years = years;
return this;
Expand Down Expand Up @@ -82,6 +85,27 @@ public void setChallengeCounts(List<Integer> challengeCounts) {
this.challengeCounts = challengeCounts;
}

public ChallengesPerYearDto undatedChallengeCount(Integer undatedChallengeCount) {
this.undatedChallengeCount = undatedChallengeCount;
return this;
}

/**
* Get undatedChallengeCount minimum: 0
*
* @return undatedChallengeCount
*/
@NotNull
@Min(0)
@Schema(name = "undatedChallengeCount", example = "0", required = true)
public Integer getUndatedChallengeCount() {
return undatedChallengeCount;
}

public void setUndatedChallengeCount(Integer undatedChallengeCount) {
this.undatedChallengeCount = undatedChallengeCount;
}

@Override
public boolean equals(Object o) {
if (this == o) {
Expand All @@ -92,12 +116,13 @@ public boolean equals(Object o) {
}
ChallengesPerYearDto challengesPerYear = (ChallengesPerYearDto) o;
return Objects.equals(this.years, challengesPerYear.years)
&& Objects.equals(this.challengeCounts, challengesPerYear.challengeCounts);
&& Objects.equals(this.challengeCounts, challengesPerYear.challengeCounts)
&& Objects.equals(this.undatedChallengeCount, challengesPerYear.undatedChallengeCount);
}

@Override
public int hashCode() {
return Objects.hash(years, challengeCounts);
return Objects.hash(years, challengeCounts, undatedChallengeCount);
}

@Override
Expand All @@ -106,6 +131,9 @@ public String toString() {
sb.append("class ChallengesPerYearDto {\n");
sb.append(" years: ").append(toIndentedString(years)).append("\n");
sb.append(" challengeCounts: ").append(toIndentedString(challengeCounts)).append("\n");
sb.append(" undatedChallengeCount: ")
.append(toIndentedString(undatedChallengeCount))
.append("\n");
sb.append("}");
return sb.toString();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@ public ChallengesPerYearDto getChallengesPerYear() {
"2018", "2019", "2020", "2021", "2022", "2023");
List<Integer> challengeCounts =
Arrays.asList(5, 8, 12, 16, 21, 27, 31, 38, 45, 54, 80, 91, 110, 129, 177, 203, 226);
Integer undatedChallengeCount = 50;

return ChallengesPerYearDto.builder().years(years).challengeCounts(challengeCounts).build();
return ChallengesPerYearDto.builder()
.years(years)
.challengeCounts(challengeCounts)
.undatedChallengeCount(undatedChallengeCount)
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -876,6 +876,7 @@ components:
ChallengesPerYear:
description: An object
example:
undatedChallengeCount: 0
challengeCounts:
- 0
- 0
Expand All @@ -891,8 +892,14 @@ components:
items:
type: integer
type: array
undatedChallengeCount:
rrchai marked this conversation as resolved.
Show resolved Hide resolved
default: 0
example: 0
minimum: 0
type: integer
required:
- challengeCounts
- undatedChallengeCount
- years
type: object
x-java-class-annotations:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,6 @@
export interface ChallengesPerYear {
years: Array<string>;
challengeCounts: Array<number>;
undatedChallengeCount: number;
}

Original file line number Diff line number Diff line change
Expand Up @@ -614,9 +614,15 @@ components:
type: array
items:
type: integer
undatedChallengeCount:
type: integer
default: 0
minimum: 0
example: 0
required:
- years
- challengeCounts
- undatedChallengeCount
x-java-class-annotations:
- '@lombok.Builder'
ChallengeInputDataTypeSort:
Expand Down
6 changes: 6 additions & 0 deletions libs/openchallenges/api-description/build/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -768,9 +768,15 @@ components:
type: array
items:
type: integer
undatedChallengeCount:
type: integer
default: 0
minimum: 0
example: 0
required:
- years
- challengeCounts
- undatedChallengeCount
x-java-class-annotations:
- '@lombok.Builder'
ChallengeInputDataTypeSort:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,14 @@ properties:
type: array
items:
type: integer
undatedChallengeCount:
type: integer
default: 0
minimum: 0
example: 0
required:
- years
- challengeCounts
- undatedChallengeCount
x-java-class-annotations:
- '@lombok.Builder'
Original file line number Diff line number Diff line change
Expand Up @@ -231,8 +231,13 @@ export class ChallengeSearchComponent

// update the total number of challenges in database with empty query
this.challengeService
.listChallenges({})
.subscribe((page) => (this.totalChallengesCount = page.totalElements));
.listChallenges({ pageSize: 1, pageNumber: 0 })
.subscribe((page) => {
this.totalChallengesCount = page.totalElements;

// const num = page.challenges.filter((c) => c.startDate !== null).length;
// console.log(num);
});

// update platform filter values
this.challengeSearchDataService
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,29 @@ export class StatisticsViewerComponent implements OnInit, OnDestroy {
},
// disable default clicking
silent: true,
// make bar plot rise from left to right instead of rising all together in the same time
// make bar plot rise from left to right
// instead of rising all together in the same time
animationDelay: (dataIndex: number) => dataIndex * 100,
},
],
graphic: res.undatedChallengeCount
? {
elements: [
{
type: 'text',
style: {
text:
`*The OC database includes an additional ${res.undatedChallengeCount} challenges ` +
`without known start dates.`,
fill: '#888',
fontSize: '1em',
},
left: '25%',
bottom: 5,
},
],
}
: undefined,
})
);
}
Expand Down