From 5739e4bab4b33e4ab74b71f5f19f6dac43c67996 Mon Sep 17 00:00:00 2001 From: Kornilovich Mikhail Date: Wed, 24 Jul 2024 21:11:07 +0300 Subject: [PATCH] refactor --- .../main/kotlin/org/icpclive/overlay/Routing.kt | 5 ++--- .../src/components/organisms/holder/TimeLine.jsx | 16 +++++++--------- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/src/backend/src/main/kotlin/org/icpclive/overlay/Routing.kt b/src/backend/src/main/kotlin/org/icpclive/overlay/Routing.kt index 73075911a..6e93e9974 100644 --- a/src/backend/src/main/kotlin/org/icpclive/overlay/Routing.kt +++ b/src/backend/src/main/kotlin/org/icpclive/overlay/Routing.kt @@ -6,7 +6,6 @@ import io.ktor.server.response.* import io.ktor.server.routing.* import io.ktor.server.websocket.* import io.ktor.websocket.* -import kotlinx.collections.immutable.persistentMapOf import kotlinx.collections.immutable.toPersistentMap import kotlinx.coroutines.flow.* import org.icpclive.Config @@ -16,7 +15,7 @@ import org.icpclive.cds.api.* import org.icpclive.data.DataBus import org.icpclive.data.currentContestInfoFlow import org.icpclive.util.sendJsonFlow -import kotlin.time.DurationUnit +import kotlin.time.Duration inline fun Route.flowEndpoint(name: String, crossinline dataProvider: suspend () -> Flow) { webSocket(name) { sendJsonFlow(dataProvider()) } @@ -43,7 +42,7 @@ fun Route.configureOverlayRouting() { val acceptedProblems = mutableSetOf() val allRuns = mutableMapOf() DataBus.contestStateFlow.await().first().runsAfterEvent.values - .filter { teamId == it.teamId && it.time.toLong(DurationUnit.MILLISECONDS) != 0L } + .filter { teamId == it.teamId && it.time != Duration.ZERO } .forEach { allRuns[it.id] = it } sendJsonFlow(DataBus.contestStateFlow.await() .mapNotNull { (it.lastEvent as? RunUpdate)?.newInfo } diff --git a/src/frontend/overlay/src/components/organisms/holder/TimeLine.jsx b/src/frontend/overlay/src/components/organisms/holder/TimeLine.jsx index e704a4aca..80836321f 100644 --- a/src/frontend/overlay/src/components/organisms/holder/TimeLine.jsx +++ b/src/frontend/overlay/src/components/organisms/holder/TimeLine.jsx @@ -4,6 +4,7 @@ import { useAppSelector } from "../../../redux/hooks"; import c from "../../../config"; import { isShouldUseDarkColor } from "../../../utils/colors"; import { getIOIColor } from "../../../utils/statusInfo"; +import { RunResult } from "../../../../../generated/api"; const ChangeTextAnimation = keyframes` 0% { @@ -108,7 +109,7 @@ export const TimeLine = ({ className, teamId }) => { const [runsResults, setRunsResults] = useState([]); const getColor = (problemResult) => { - if (problemResult.type === "IN_PROGRESS") { + if (problemResult.type === RunResult.Type.IN_PROGRESS) { return c.VERDICT_UNKNOWN; } else if (problemResult.type === "ICPC") { if (problemResult.isAccepted) { @@ -128,16 +129,13 @@ export const TimeLine = ({ className, teamId }) => { return ( -