diff --git a/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/contest/scoreboard/ContestScoreboardUpdater.java b/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/contest/scoreboard/ContestScoreboardUpdater.java index 8b4d91c99..e3a7754a5 100644 --- a/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/contest/scoreboard/ContestScoreboardUpdater.java +++ b/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/contest/scoreboard/ContestScoreboardUpdater.java @@ -33,6 +33,7 @@ import judgels.uriel.api.contest.scoreboard.Scoreboard; import judgels.uriel.api.contest.scoreboard.ScoreboardEntry; import judgels.uriel.api.contest.scoreboard.ScoreboardState; +import judgels.uriel.contest.ContestStore; import judgels.uriel.contest.ContestTimer; import judgels.uriel.contest.contestant.ContestContestantStore; import judgels.uriel.contest.module.ContestModuleStore; @@ -41,6 +42,7 @@ public class ContestScoreboardUpdater { private final ObjectMapper objectMapper; private final ContestTimer contestTimer; + private final ContestStore contestStore; private final ContestScoreboardStore scoreboardStore; private final ContestModuleStore moduleStore; private final ContestContestantStore contestantStore; @@ -55,6 +57,7 @@ public class ContestScoreboardUpdater { public ContestScoreboardUpdater( ObjectMapper objectMapper, ContestTimer contestTimer, + ContestStore contestStore, ContestScoreboardStore scoreboardStore, ContestModuleStore moduleStore, ContestContestantStore contestantStore, @@ -68,6 +71,7 @@ public ContestScoreboardUpdater( this.objectMapper = objectMapper; this.contestTimer = contestTimer; + this.contestStore = contestStore; this.scoreboardStore = scoreboardStore; this.moduleStore = moduleStore; this.contestantStore = contestantStore; @@ -170,14 +174,21 @@ public void update(Contest contest) { Map scoreboards = new HashMap<>(); Map incrementalContents = new HashMap<>(); + Map freezeTimesMap = new HashMap<>(); for (ContestScoreboardType type : new ContestScoreboardType[]{OFFICIAL, FROZEN}) { - Optional freezeTime = Optional.empty(); if (type == FROZEN) { - if (!contestModulesConfig.getFrozenScoreboard().isPresent()) { + putFreezeTime(freezeTimesMap, contest); + + if (previousContestJid.isPresent()) { + Optional previousContest = contestStore.getContestByJid(previousContestJid.get()); + if (previousContest.isPresent()) { + putFreezeTime(freezeTimesMap, previousContest.get()); + } + } + + if (freezeTimesMap.isEmpty()) { continue; } - Duration duration = contestModulesConfig.getFrozenScoreboard().get().getFreezeDurationBeforeEndTime(); - freezeTime = Optional.of(contest.getEndTime().minus(duration)); } Optional incrementalContent = Optional.ofNullable( @@ -192,7 +203,7 @@ public void update(Contest contest) { profilesMap, programmingSubmissions, bundleItemSubmissions, - freezeTime); + freezeTimesMap); Scoreboard scoreboard = processor.create(state, result.getEntries()); @@ -236,4 +247,13 @@ public void update(Contest contest) { scoreboards); } } + + private void putFreezeTime(Map freezeTimesMap, Contest contest) { + ContestModulesConfig config = moduleStore.getConfig(contest.getJid(), contest.getStyle()); + + if (config.getFrozenScoreboard().isPresent()) { + Duration duration = config.getFrozenScoreboard().get().getFreezeDurationBeforeEndTime(); + freezeTimesMap.put(contest.getJid(), contest.getEndTime().minus(duration)); + } + } } diff --git a/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/contest/scoreboard/ContestScoreboardUpdaterModule.java b/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/contest/scoreboard/ContestScoreboardUpdaterModule.java index ce68f884c..46e2fbe94 100644 --- a/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/contest/scoreboard/ContestScoreboardUpdaterModule.java +++ b/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/contest/scoreboard/ContestScoreboardUpdaterModule.java @@ -48,6 +48,7 @@ static ContestScoreboardUpdater contestScoreboardUpdater( UnitOfWorkAwareProxyFactory unitOfWorkAwareProxyFactory, ObjectMapper objectMapper, ContestTimer contestTimer, + ContestStore contestStore, ContestScoreboardStore scoreboardStore, ContestModuleStore moduleStore, ContestContestantStore contestantStore, @@ -64,6 +65,7 @@ static ContestScoreboardUpdater contestScoreboardUpdater( new Class[] { ObjectMapper.class, ContestTimer.class, + ContestStore.class, ContestScoreboardStore.class, ContestModuleStore.class, ContestContestantStore.class, @@ -77,6 +79,7 @@ static ContestScoreboardUpdater contestScoreboardUpdater( new Object[] { objectMapper, contestTimer, + contestStore, scoreboardStore, moduleStore, contestantStore, diff --git a/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/contest/scoreboard/ScoreboardProcessor.java b/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/contest/scoreboard/ScoreboardProcessor.java index 6fa91b1f9..fb87e4b3e 100644 --- a/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/contest/scoreboard/ScoreboardProcessor.java +++ b/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/contest/scoreboard/ScoreboardProcessor.java @@ -31,7 +31,7 @@ ScoreboardProcessResult process( Map profilesMap, List programmingSubmissions, List bundleItemSubmissions, - Optional freezeTime); + Map freezeTimesMap); ScoreboardEntry clearEntryRank(ScoreboardEntry entry); } diff --git a/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/contest/scoreboard/bundle/BundleScoreboardProcessor.java b/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/contest/scoreboard/bundle/BundleScoreboardProcessor.java index df4261af3..f1885806c 100644 --- a/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/contest/scoreboard/bundle/BundleScoreboardProcessor.java +++ b/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/contest/scoreboard/bundle/BundleScoreboardProcessor.java @@ -63,7 +63,7 @@ public ScoreboardProcessResult process( Map profilesMap, List programmingSubmissions, List bundleItemSubmissions, - Optional freezeTime) { + Map freezeTimesMap) { List problemJids = scoreboardState.getProblemJids(); Set contestantJids = contestants.stream().map(ContestContestant::getUserJid).collect(toSet()); diff --git a/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/contest/scoreboard/gcj/GcjScoreboardProcessor.java b/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/contest/scoreboard/gcj/GcjScoreboardProcessor.java index b23373749..a79b5dafb 100644 --- a/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/contest/scoreboard/gcj/GcjScoreboardProcessor.java +++ b/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/contest/scoreboard/gcj/GcjScoreboardProcessor.java @@ -72,7 +72,7 @@ public ScoreboardProcessResult process( Map profilesMap, List programmingSubmissions, List bundleItemSubmissions, - Optional freezeTime) { + Map freezeTimesMap) { GcjStyleModuleConfig gcjStyleModuleConfig = (GcjStyleModuleConfig) styleModuleConfig; @@ -137,7 +137,7 @@ public ScoreboardProcessResult process( for (Submission submission : submissionsMap.get(contestantJid)) { String problemJid = submission.getProblemJid(); - if (submission.getTime().isBefore(freezeTime.orElse(Instant.MAX))) { + if (submission.getTime().isBefore(freezeTimesMap.getOrDefault(submission.getContainerJid(), Instant.MAX))) { Verdict verdict = submission.getLatestGrading().get().getVerdict(); if (verdict.equals(Verdict.PENDING)) { continue; diff --git a/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/contest/scoreboard/icpc/IcpcScoreboardProcessor.java b/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/contest/scoreboard/icpc/IcpcScoreboardProcessor.java index a97f9997c..9a5fd0885 100644 --- a/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/contest/scoreboard/icpc/IcpcScoreboardProcessor.java +++ b/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/contest/scoreboard/icpc/IcpcScoreboardProcessor.java @@ -72,7 +72,7 @@ public ScoreboardProcessResult process( Map profilesMap, List programmingSubmissions, List bundleItemSubmissions, - Optional freezeTime) { + Map freezeTimesMap) { IcpcStyleModuleConfig icpcStyleModuleConfig = (IcpcStyleModuleConfig) styleModuleConfig; @@ -142,7 +142,7 @@ public ScoreboardProcessResult process( continue; } - if (submission.getTime().isBefore(freezeTime.orElse(Instant.MAX))) { + if (submission.getTime().isBefore(freezeTimesMap.getOrDefault(submission.getContainerJid(), Instant.MAX))) { Verdict verdict = submission.getLatestGrading().get().getVerdict(); if (verdict.equals(Verdict.PENDING)) { continue; diff --git a/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/contest/scoreboard/ioi/IoiScoreboardProcessor.java b/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/contest/scoreboard/ioi/IoiScoreboardProcessor.java index a1f14dcc9..c94624690 100644 --- a/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/contest/scoreboard/ioi/IoiScoreboardProcessor.java +++ b/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/contest/scoreboard/ioi/IoiScoreboardProcessor.java @@ -74,7 +74,7 @@ public ScoreboardProcessResult process( Map profilesMap, List programmingSubmissions, List bundleItemSubmissions, - Optional freezeTime) { + Map freezeTimesMap) { IoiStyleModuleConfig ioiStyleModuleConfig = (IoiStyleModuleConfig) styleModuleConfig; @@ -158,7 +158,7 @@ public ScoreboardProcessResult process( score = grading.getScore(); } - if (submission.getTime().isBefore(freezeTime.orElse(Instant.MAX))) { + if (submission.getTime().isBefore(freezeTimesMap.getOrDefault(submission.getContainerJid(), Instant.MAX))) { if (!scoresMap.get(problemJid).isPresent() || score > scoresMap.get(problemJid).get()) { scoresMap.put(problemJid, Optional.of(score)); diff --git a/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/contest/scoreboard/troc/TrocScoreboardProcessor.java b/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/contest/scoreboard/troc/TrocScoreboardProcessor.java index fe3c2df2a..cbad51454 100644 --- a/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/contest/scoreboard/troc/TrocScoreboardProcessor.java +++ b/judgels-backends/judgels-server-app/src/main/java/judgels/uriel/contest/scoreboard/troc/TrocScoreboardProcessor.java @@ -72,7 +72,7 @@ public ScoreboardProcessResult process( Map profilesMap, List programmingSubmissions, List bundleItemSubmissions, - Optional freezeTime) { + Map freezeTimesMap) { TrocStyleModuleConfig trocStyleModuleConfig = (TrocStyleModuleConfig) styleModuleConfig; List problemJids = scoreboardState.getProblemJids(); @@ -145,7 +145,7 @@ public ScoreboardProcessResult process( continue; } - if (submission.getTime().isBefore(freezeTime.orElse(Instant.MAX))) { + if (submission.getTime().isBefore(freezeTimesMap.getOrDefault(submission.getContainerJid(), Instant.MAX))) { Verdict verdict = submission.getLatestGrading().get().getVerdict(); if (verdict.equals(Verdict.PENDING) || verdict.equals(Verdict.COMPILATION_ERROR)) { continue; diff --git a/judgels-backends/judgels-server-app/src/test/java/judgels/uriel/contest/scoreboard/bundle/BundleScoreboardProcessorTests.java b/judgels-backends/judgels-server-app/src/test/java/judgels/uriel/contest/scoreboard/bundle/BundleScoreboardProcessorTests.java index c98297dde..cb06bc791 100644 --- a/judgels-backends/judgels-server-app/src/test/java/judgels/uriel/contest/scoreboard/bundle/BundleScoreboardProcessorTests.java +++ b/judgels-backends/judgels-server-app/src/test/java/judgels/uriel/contest/scoreboard/bundle/BundleScoreboardProcessorTests.java @@ -123,7 +123,7 @@ void latest_answered_time_calculation() { profilesMap, ImmutableList.of(), submissions, - Optional.empty()); + Map.of()); assertThat(Lists.transform(result.getEntries(), e -> (BundleScoreboardEntry) e)).containsExactly( new BundleScoreboardEntry.Builder() @@ -198,7 +198,7 @@ void total_answered_items_over_last_answered_time() { profilesMap, ImmutableList.of(), submissions, - Optional.empty()); + Map.of()); assertThat(Lists.transform(result.getEntries(), e -> (BundleScoreboardEntry) e)).containsExactly( new BundleScoreboardEntry.Builder() @@ -257,7 +257,7 @@ void last_answered_time_as_tiebreaker() { profilesMap, ImmutableList.of(), submissions, - Optional.empty()); + Map.of()); assertThat(Lists.transform(result.getEntries(), e -> (BundleScoreboardEntry) e)).containsExactly( new BundleScoreboardEntry.Builder() diff --git a/judgels-backends/judgels-server-app/src/test/java/judgels/uriel/contest/scoreboard/gcj/GcjScoreboardProcessorTests.java b/judgels-backends/judgels-server-app/src/test/java/judgels/uriel/contest/scoreboard/gcj/GcjScoreboardProcessorTests.java index c6d2374b6..7a5c450a3 100644 --- a/judgels-backends/judgels-server-app/src/test/java/judgels/uriel/contest/scoreboard/gcj/GcjScoreboardProcessorTests.java +++ b/judgels-backends/judgels-server-app/src/test/java/judgels/uriel/contest/scoreboard/gcj/GcjScoreboardProcessorTests.java @@ -79,7 +79,7 @@ void time_calculation() { profilesMap, submissions, ImmutableList.of(), - Optional.empty()); + Map.of()); assertThat(Lists.transform(result.getEntries(), e -> (GcjScoreboardEntry) e)).containsExactly( new GcjScoreboardEntry.Builder() @@ -129,7 +129,7 @@ void base_case() { profilesMap, submissions, ImmutableList.of(), - Optional.empty()); + Map.of()); assertThat(Lists.transform(result.getEntries(), e -> (GcjScoreboardEntry) e)).containsExactly( new GcjScoreboardEntry.Builder() @@ -179,7 +179,7 @@ void reversed_case() { profilesMap, submissions, ImmutableList.of(), - Optional.empty()); + Map.of()); assertThat(Lists.transform(result.getEntries(), e -> (GcjScoreboardEntry) e)).containsExactly( new GcjScoreboardEntry.Builder() @@ -230,7 +230,7 @@ void points_over_penalty() { profilesMap, submissions, ImmutableList.of(), - Optional.empty()); + Map.of()); assertThat(Lists.transform(result.getEntries(), e -> (GcjScoreboardEntry) e)).containsExactly( new GcjScoreboardEntry.Builder() @@ -278,7 +278,7 @@ void penalty_as_tiebreaker() { profilesMap, submissions, ImmutableList.of(), - Optional.empty()); + Map.of()); assertThat(Lists.transform(result.getEntries(), e -> (GcjScoreboardEntry) e)).containsExactly( new GcjScoreboardEntry.Builder() @@ -339,7 +339,7 @@ void same_rank_if_equal() { profilesMap, submissions, ImmutableList.of(), - Optional.empty()); + Map.of()); assertThat(Lists.transform(result.getEntries(), e -> (GcjScoreboardEntry) e)).containsExactly( new GcjScoreboardEntry.Builder() @@ -412,7 +412,7 @@ void zero_points_ordering() { profilesMap, submissions, ImmutableList.of(), - Optional.empty()); + Map.of()); assertThat(Lists.transform(result.getEntries(), e -> (GcjScoreboardEntry) e)).containsExactly( new GcjScoreboardEntry.Builder() @@ -462,7 +462,7 @@ void zero_points_ordering() { @Nested class PendingAfterFreeze { - private Optional freezeTime = Optional.of(Instant.ofEpochSecond(500)); + private Map freezeTimesMap = Map.of(contest.getJid(), Instant.ofEpochSecond(500)); private List baseSubmissions = ImmutableList.of( createSubmission(1, 100, "c1", "p1", 100, Verdict.ACCEPTED), @@ -480,7 +480,7 @@ void no_pending() { profilesMap, baseSubmissions, ImmutableList.of(), - freezeTime); + freezeTimesMap); assertThat(Lists.transform(result.getEntries(), e -> (GcjScoreboardEntry) e)).containsExactly( new GcjScoreboardEntry.Builder() @@ -529,7 +529,7 @@ void pending_does_not_overwrite_accepted() { profilesMap, submissions, ImmutableList.of(), - freezeTime); + freezeTimesMap); assertThat(Lists.transform(result.getEntries(), e -> (GcjScoreboardEntry) e)).containsExactly( new GcjScoreboardEntry.Builder() @@ -578,7 +578,7 @@ void pending_does_overwrite_not_accepted() { profilesMap, submissions, ImmutableList.of(), - freezeTime); + freezeTimesMap); assertThat(Lists.transform(result.getEntries(), e -> (GcjScoreboardEntry) e)).containsExactly( new GcjScoreboardEntry.Builder() @@ -627,7 +627,7 @@ void pending_counts_on_freeze_time() { profilesMap, submissions, ImmutableList.of(), - freezeTime); + freezeTimesMap); assertThat(Lists.transform(result.getEntries(), e -> (GcjScoreboardEntry) e)).containsExactly( new GcjScoreboardEntry.Builder() @@ -707,7 +707,7 @@ void empty_initial_incremental_content() { profilesMap, submissions, ImmutableList.of(), - Optional.empty()); + Map.of()); assertThat(result.getIncrementalContent()).isEqualTo(new GcjScoreboardIncrementalContent.Builder() .lastSubmissionId(9) @@ -735,7 +735,7 @@ void empty_new_submissions() { profilesMap, ImmutableList.of(), ImmutableList.of(), - Optional.empty()); + Map.of()); assertThat(result.getIncrementalContent()).isEqualTo(new GcjScoreboardIncrementalContent.Builder() .from(incrementalContent) @@ -754,7 +754,7 @@ void existing_incremental_content() { profilesMap, submissions, ImmutableList.of(), - Optional.empty()); + Map.of()); assertThat(result.getIncrementalContent()).isEqualTo(new GcjScoreboardIncrementalContent.Builder() .lastSubmissionId(9) diff --git a/judgels-backends/judgels-server-app/src/test/java/judgels/uriel/contest/scoreboard/icpc/IcpcScoreboardProcessorTests.java b/judgels-backends/judgels-server-app/src/test/java/judgels/uriel/contest/scoreboard/icpc/IcpcScoreboardProcessorTests.java index ebb4a2a0c..190fcc093 100644 --- a/judgels-backends/judgels-server-app/src/test/java/judgels/uriel/contest/scoreboard/icpc/IcpcScoreboardProcessorTests.java +++ b/judgels-backends/judgels-server-app/src/test/java/judgels/uriel/contest/scoreboard/icpc/IcpcScoreboardProcessorTests.java @@ -78,7 +78,7 @@ void time_calculation() { profilesMap, submissions, ImmutableList.of(), - Optional.empty()); + Map.of()); assertThat(Lists.transform(result.getEntries(), e -> (IcpcScoreboardEntry) e)).containsExactly( new IcpcScoreboardEntry.Builder() @@ -130,7 +130,7 @@ void base_case() { profilesMap, submissions, ImmutableList.of(), - Optional.empty()); + Map.of()); assertThat(Lists.transform(result.getEntries(), e -> (IcpcScoreboardEntry) e)).containsExactly( new IcpcScoreboardEntry.Builder() @@ -181,7 +181,7 @@ void reversed_case() { profilesMap, submissions, ImmutableList.of(), - Optional.empty()); + Map.of()); assertThat(Lists.transform(result.getEntries(), e -> (IcpcScoreboardEntry) e)).containsExactly( new IcpcScoreboardEntry.Builder() @@ -235,7 +235,7 @@ void solve_over_penalty() { profilesMap, submissions, ImmutableList.of(), - Optional.empty()); + Map.of()); assertThat(Lists.transform(result.getEntries(), e -> (IcpcScoreboardEntry) e)).containsExactly( new IcpcScoreboardEntry.Builder() @@ -285,7 +285,7 @@ void penalty_as_tiebreaker() { profilesMap, submissions, ImmutableList.of(), - Optional.empty()); + Map.of()); assertThat(Lists.transform(result.getEntries(), e -> (IcpcScoreboardEntry) e)).containsExactly( new IcpcScoreboardEntry.Builder() @@ -349,7 +349,7 @@ void same_rank_if_equal() { profilesMap, submissions, ImmutableList.of(), - Optional.empty()); + Map.of()); assertThat(Lists.transform(result.getEntries(), e -> (IcpcScoreboardEntry) e)).containsExactly( new IcpcScoreboardEntry.Builder() @@ -425,7 +425,7 @@ void zero_points_ordering() { profilesMap, submissions, ImmutableList.of(), - Optional.empty()); + Map.of()); assertThat(Lists.transform(result.getEntries(), e -> (IcpcScoreboardEntry) e)).containsExactly( new IcpcScoreboardEntry.Builder() @@ -478,7 +478,7 @@ void zero_points_ordering() { @Nested class PendingAfterFreeze { - private Optional freezeTime = Optional.of(Instant.ofEpochSecond(500)); + private Map freezeTimesMap = Map.of(contest.getJid(), Instant.ofEpochSecond(500)); private List baseSubmissions = ImmutableList.of( createSubmission(1, 100, "c1", "p1", 100, Verdict.ACCEPTED), @@ -496,7 +496,7 @@ void no_pending() { profilesMap, baseSubmissions, ImmutableList.of(), - freezeTime); + freezeTimesMap); assertThat(Lists.transform(result.getEntries(), e -> (IcpcScoreboardEntry) e)).containsExactly( new IcpcScoreboardEntry.Builder() @@ -547,7 +547,7 @@ void pending_does_not_overwrite_accepted() { profilesMap, submissions, ImmutableList.of(), - freezeTime); + freezeTimesMap); assertThat(Lists.transform(result.getEntries(), e -> (IcpcScoreboardEntry) e)).containsExactly( new IcpcScoreboardEntry.Builder() @@ -598,7 +598,7 @@ void pending_does_overwrite_not_accepted() { profilesMap, submissions, ImmutableList.of(), - freezeTime); + freezeTimesMap); assertThat(Lists.transform(result.getEntries(), e -> (IcpcScoreboardEntry) e)).containsExactly( new IcpcScoreboardEntry.Builder() @@ -649,7 +649,7 @@ void pending_counts_on_freeze_time() { profilesMap, submissions, ImmutableList.of(), - freezeTime); + freezeTimesMap); assertThat(Lists.transform(result.getEntries(), e -> (IcpcScoreboardEntry) e)).containsExactly( new IcpcScoreboardEntry.Builder() @@ -734,7 +734,7 @@ void empty_initial_incremental_content() { profilesMap, submissions, ImmutableList.of(), - Optional.empty()); + Map.of()); assertThat(result.getIncrementalContent()).isEqualTo(new IcpcScoreboardIncrementalContent.Builder() .lastSubmissionId(9) @@ -766,7 +766,7 @@ void empty_new_submissions() { profilesMap, ImmutableList.of(), ImmutableList.of(), - Optional.empty()); + Map.of()); assertThat(result.getIncrementalContent()).isEqualTo(new IcpcScoreboardIncrementalContent.Builder() .from(incrementalContent) @@ -785,7 +785,7 @@ void existing_incremental_content() { profilesMap, submissions, ImmutableList.of(), - Optional.empty()); + Map.of()); assertThat(result.getIncrementalContent()).isEqualTo(new IcpcScoreboardIncrementalContent.Builder() .lastSubmissionId(9) diff --git a/judgels-backends/judgels-server-app/src/test/java/judgels/uriel/contest/scoreboard/ioi/IoiScoreboardProcessorTests.java b/judgels-backends/judgels-server-app/src/test/java/judgels/uriel/contest/scoreboard/ioi/IoiScoreboardProcessorTests.java index 911f65fbf..493e28530 100644 --- a/judgels-backends/judgels-server-app/src/test/java/judgels/uriel/contest/scoreboard/ioi/IoiScoreboardProcessorTests.java +++ b/judgels-backends/judgels-server-app/src/test/java/judgels/uriel/contest/scoreboard/ioi/IoiScoreboardProcessorTests.java @@ -78,7 +78,7 @@ void time_calculation() { profilesMap, submissions, ImmutableList.of(), - Optional.empty()); + Map.of()); assertThat(Lists.transform(result.getEntries(), e -> (IoiScoreboardEntry) e)).containsExactly( new IoiScoreboardEntry.Builder() @@ -123,7 +123,7 @@ void frozen() { profilesMap, submissions, ImmutableList.of(), - Optional.of(Instant.ofEpochMilli(23))); + Map.of(contest.getJid(), Instant.ofEpochMilli(23))); assertThat(Lists.transform(result.getEntries(), e -> (IoiScoreboardEntry) e)).containsExactly( new IoiScoreboardEntry.Builder() @@ -188,7 +188,7 @@ void empty_initial_incremental_content() { profilesMap, submissions, ImmutableList.of(), - Optional.empty()); + Map.of()); assertThat(Lists.transform(result.getEntries(), e -> (IoiScoreboardEntry) e)).containsExactly( new IoiScoreboardEntry.Builder() @@ -242,7 +242,7 @@ void existing_incremental_content() { profilesMap, submissions, ImmutableList.of(), - Optional.empty()); + Map.of()); assertThat(Lists.transform(result.getEntries(), e -> (IoiScoreboardEntry) e)).containsExactly( new IoiScoreboardEntry.Builder() @@ -303,7 +303,7 @@ void base_case() { profilesMap, submissions, ImmutableList.of(), - Optional.empty()); + Map.of()); assertThat(Lists.transform(result.getEntries(), e -> (IoiScoreboardEntry) e)).containsExactly( new IoiScoreboardEntry.Builder() @@ -348,7 +348,7 @@ void reversed_case() { profilesMap, submissions, ImmutableList.of(), - Optional.empty()); + Map.of()); assertThat(Lists.transform(result.getEntries(), e -> (IoiScoreboardEntry) e)).containsExactly( new IoiScoreboardEntry.Builder() @@ -397,7 +397,7 @@ void sorted_without_last_affecting_penalty() { profilesMap, submissions, ImmutableList.of(), - Optional.empty()); + Map.of()); assertThat(Lists.transform(result.getEntries(), e -> (IoiScoreboardEntry) e)).containsExactly( new IoiScoreboardEntry.Builder() @@ -439,7 +439,7 @@ void sorted_with_last_affecting_penalty() { profilesMap, submissions, ImmutableList.of(), - Optional.empty()); + Map.of()); assertThat(Lists.transform(result.getEntries(), e -> (IoiScoreboardEntry) e)).containsExactly( new IoiScoreboardEntry.Builder() @@ -509,7 +509,7 @@ void empty_initial_incremental_content() { profilesMap, submissions, ImmutableList.of(), - Optional.empty()); + Map.of()); assertThat(result.getIncrementalContent()).isEqualTo(new IoiScoreboardIncrementalContent.Builder() .lastSubmissionId(9) @@ -537,7 +537,7 @@ void empty_new_submissions() { profilesMap, ImmutableList.of(), ImmutableList.of(), - Optional.empty()); + Map.of()); assertThat(result.getIncrementalContent()).isEqualTo(new IoiScoreboardIncrementalContent.Builder() .from(incrementalContent) @@ -556,7 +556,7 @@ void existing_incremental_content() { profilesMap, submissions, ImmutableList.of(), - Optional.empty()); + Map.of()); assertThat(result.getIncrementalContent()).isEqualTo(new IoiScoreboardIncrementalContent.Builder() .lastSubmissionId(9) diff --git a/judgels-backends/judgels-server-app/src/test/java/judgels/uriel/contest/scoreboard/troc/TrocScoreboardProcessorTests.java b/judgels-backends/judgels-server-app/src/test/java/judgels/uriel/contest/scoreboard/troc/TrocScoreboardProcessorTests.java index 02b6d7871..eb12ec9a9 100644 --- a/judgels-backends/judgels-server-app/src/test/java/judgels/uriel/contest/scoreboard/troc/TrocScoreboardProcessorTests.java +++ b/judgels-backends/judgels-server-app/src/test/java/judgels/uriel/contest/scoreboard/troc/TrocScoreboardProcessorTests.java @@ -83,7 +83,7 @@ void time_calculation() { profilesMap, submissions, ImmutableList.of(), - Optional.empty()); + Map.of()); assertThat(Lists.transform(result.getEntries(), e -> (TrocScoreboardEntry) e)).containsExactly( new TrocScoreboardEntry.Builder() @@ -133,7 +133,7 @@ void base_case() { profilesMap, submissions, ImmutableList.of(), - Optional.empty()); + Map.of()); assertThat(Lists.transform(result.getEntries(), e -> (TrocScoreboardEntry) e)).containsExactly( new TrocScoreboardEntry.Builder() @@ -183,7 +183,7 @@ void reversed_case() { profilesMap, submissions, ImmutableList.of(), - Optional.empty()); + Map.of()); assertThat(Lists.transform(result.getEntries(), e -> (TrocScoreboardEntry) e)).containsExactly( new TrocScoreboardEntry.Builder() @@ -234,7 +234,7 @@ void points_over_penalty() { profilesMap, submissions, ImmutableList.of(), - Optional.empty()); + Map.of()); assertThat(Lists.transform(result.getEntries(), e -> (TrocScoreboardEntry) e)).containsExactly( new TrocScoreboardEntry.Builder() @@ -282,7 +282,7 @@ void penalty_as_tiebreaker() { profilesMap, submissions, ImmutableList.of(), - Optional.empty()); + Map.of()); assertThat(Lists.transform(result.getEntries(), e -> (TrocScoreboardEntry) e)).containsExactly( new TrocScoreboardEntry.Builder() @@ -343,7 +343,7 @@ void same_rank_if_equal() { profilesMap, submissions, ImmutableList.of(), - Optional.empty()); + Map.of()); assertThat(Lists.transform(result.getEntries(), e -> (TrocScoreboardEntry) e)).containsExactly( new TrocScoreboardEntry.Builder() @@ -416,7 +416,7 @@ void zero_points_ordering() { profilesMap, submissions, ImmutableList.of(), - Optional.empty()); + Map.of()); assertThat(Lists.transform(result.getEntries(), e -> (TrocScoreboardEntry) e)).containsExactly( new TrocScoreboardEntry.Builder() @@ -466,7 +466,7 @@ void zero_points_ordering() { @Nested class PendingAfterFreeze { - private Optional freezeTime = Optional.of(Instant.ofEpochSecond(500)); + private Map freezeTimesMap = Map.of(contest.getJid(), Instant.ofEpochSecond(500)); private List baseSubmissions = ImmutableList.of( createSubmission(1, 100, "c1", "p1", 100, Verdict.ACCEPTED), @@ -484,7 +484,7 @@ void no_pending() { profilesMap, baseSubmissions, ImmutableList.of(), - freezeTime); + freezeTimesMap); assertThat(Lists.transform(result.getEntries(), e -> (TrocScoreboardEntry) e)).containsExactly( new TrocScoreboardEntry.Builder() @@ -533,7 +533,7 @@ void pending_does_not_overwrite_accepted() { profilesMap, submissions, ImmutableList.of(), - freezeTime); + freezeTimesMap); assertThat(Lists.transform(result.getEntries(), e -> (TrocScoreboardEntry) e)).containsExactly( new TrocScoreboardEntry.Builder() @@ -582,7 +582,7 @@ void pending_does_overwrite_not_accepted() { profilesMap, submissions, ImmutableList.of(), - freezeTime); + freezeTimesMap); assertThat(Lists.transform(result.getEntries(), e -> (TrocScoreboardEntry) e)).containsExactly( new TrocScoreboardEntry.Builder() @@ -631,7 +631,7 @@ void pending_counts_on_freeze_time() { profilesMap, submissions, ImmutableList.of(), - freezeTime); + freezeTimesMap); assertThat(Lists.transform(result.getEntries(), e -> (TrocScoreboardEntry) e)).containsExactly( new TrocScoreboardEntry.Builder() @@ -712,7 +712,7 @@ void empty_initial_incremental_content() { profilesMap, submissions, ImmutableList.of(), - Optional.empty()); + Map.of()); assertThat(result.getIncrementalContent()).isEqualTo(new TrocScoreboardIncrementalContent.Builder() .lastSubmissionId(9) @@ -742,7 +742,7 @@ void empty_new_submissions() { profilesMap, ImmutableList.of(), ImmutableList.of(), - Optional.empty()); + Map.of()); assertThat(result.getIncrementalContent()).isEqualTo(new TrocScoreboardIncrementalContent.Builder() .from(incrementalContent) @@ -761,7 +761,7 @@ void existing_incremental_content() { profilesMap, submissions, ImmutableList.of(), - Optional.empty()); + Map.of()); assertThat(result.getIncrementalContent()).isEqualTo(new TrocScoreboardIncrementalContent.Builder() .lastSubmissionId(9)