Skip to content

Commit

Permalink
Fix scoreboard updates during freeze time
Browse files Browse the repository at this point in the history
  • Loading branch information
kunyavskiy committed Apr 16, 2024
1 parent 9705e42 commit 2055f1d
Showing 1 changed file with 5 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,8 @@ public class ContestStateWithScoreboard internal constructor(
public val lastSubmissionTime: Duration,
)

private fun RunInfo.isTested() = !isHidden && result !is RunResult.InProgress

public fun Flow<ContestUpdate>.calculateScoreboard(optimismLevel: OptimismLevel): Flow<ContestStateWithScoreboard> = flow {
var rows = persistentMapOf<TeamId, ScoreboardRow>()
var lastRanking = Ranking(emptyList(), emptyList(), emptyList())
Expand All @@ -211,13 +213,9 @@ public fun Flow<ContestUpdate>.calculateScoreboard(optimismLevel: OptimismLevel)
}
lastSubmissionTime = maxOf(lastSubmissionTime, newRun.time)

val oldRunTested = oldRun != null && !oldRun.isHidden && oldRun.result !is RunResult.InProgress
val newRunTested = !newRun.isHidden && newRun.result !is RunResult.InProgress
if (!oldRunTested && !newRunTested)
emptyList()
else {
listOfNotNull(oldRun?.teamId, newRun.teamId).distinct()
}
listOfNotNull(oldRun?.teamId, newRun.teamId).distinct().takeIf {
oldRun == null || oldRun.isTested() || newRun.isTested()
} ?: emptyList()
}
}
val teamsReallyAffected = teamsAffected.filter {
Expand Down

0 comments on commit 2055f1d

Please sign in to comment.