Skip to content

Commit

Permalink
fix(server): fix crash when there is no rating events yet (#564)
Browse files Browse the repository at this point in the history
  • Loading branch information
fushar committed Dec 16, 2023
1 parent 906eb7b commit 4982805
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import org.immutables.value.Value;

@Value.Immutable
@JsonDeserialize(as = ImmutableContestRating.class)
@JsonDeserialize(as = ImmutableContestRatingChanges.class)
public interface ContestRatingChanges {
Map<String, UserRating> getRatingsMap();
Map<String, Profile> getProfilesMap();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package judgels.uriel.api;

import static org.assertj.core.api.Assertions.assertThat;

import judgels.uriel.ContestRatingClient;
import org.junit.jupiter.api.Test;

class ContestRatingApiIntegrationTests extends BaseUrielApiIntegrationTests {
private final ContestRatingClient ratingClient = createClient(ContestRatingClient.class);

@Test
void get_pending_ratings() {
assertThat(ratingClient.getContestsPendingRating(superadminToken).getData())
.isEmpty();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public ContestsPendingRatingResponse getContestsPendingRating(@HeaderParam(AUTHO
checkAllowed(contestRoleChecker.canAdminister(actorJid));

Optional<RatingEvent> latestEvent = jophielClient.getLatestRatingEvent();
Instant latestTime = latestEvent.isPresent() ? latestEvent.get().getTime() : Instant.MIN;
Instant latestTime = latestEvent.isPresent() ? latestEvent.get().getTime() : Instant.EPOCH;

List<Contest> contests = contestStore.getPublicContestsAfter(latestTime);
Map<String, ContestRatingChanges> ratingChangesMap = contests.stream()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package judgels.uriel;

import feign.Headers;
import feign.Param;
import feign.RequestLine;
import judgels.uriel.api.contest.rating.ContestsPendingRatingResponse;

public interface ContestRatingClient {
@RequestLine("GET /api/v2/contest-rating/pending")
@Headers("Authorization: Bearer {token}")
ContestsPendingRatingResponse getContestsPendingRating(@Param("token") String token);
}

0 comments on commit 4982805

Please sign in to comment.