Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
Mond1c committed Jul 24, 2024
1 parent d239d00 commit 5739e4b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
5 changes: 2 additions & 3 deletions src/backend/src/main/kotlin/org/icpclive/overlay/Routing.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 <reified T : Any> Route.flowEndpoint(name: String, crossinline dataProvider: suspend () -> Flow<T>) {
webSocket(name) { sendJsonFlow(dataProvider()) }
Expand All @@ -43,7 +42,7 @@ fun Route.configureOverlayRouting() {
val acceptedProblems = mutableSetOf<ProblemId>()
val allRuns = mutableMapOf<RunId, RunInfo>()
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 }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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% {
Expand Down Expand Up @@ -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) {
Expand All @@ -128,16 +129,13 @@ export const TimeLine = ({ className, teamId }) => {
return (
<ProblemWrap left={left + "%"}>
<Circle color={getColor(problemResult)}>
<Label darkText={darkText} isBold={problemResult.type === "IN_PROGRESS"}>
{(problemResult.type === "IOI" || problemResult.type === "ICPC"
<Label darkText={darkText} isBold={problemResult.type === RunResult.Type.IN_PROGRESS}>
{(problemResult.type === RunResult.Type.IOI || problemResult.type === RunResult.Type.ICPC
&& !problemResult.isAccepted) && <TextWithAnimation>{problemResult.problemId}</TextWithAnimation> }
{!(problemResult.type === "IOI" || problemResult.type === "ICPC"
{!(problemResult.type === RunResult.Type.IOI || problemResult.type === RunResult.Type.ICPC
&& !problemResult.isAccepted) && <Text>{problemResult.problemId}</Text>}
{problemResult.type === "ICPC" && !problemResult.isAccepted && <TextWithAnimation2>{problemResult.shortName}</TextWithAnimation2>}
{problemResult.type === "IOI" && <TextWithAnimation2>{problemResult.score}</TextWithAnimation2>}
{/*{problemResult.problemId} <br/>*/}
{/*{problemResult.type === "IOI" && problemResult.score}*/}
{/*{problemResult.type === "ICPC" && !problemResult.isAccepted && problemResult.shortName}*/}
{problemResult.type === RunResult.Type.ICPC && !problemResult.isAccepted && <TextWithAnimation2>{problemResult.shortName}</TextWithAnimation2>}
{problemResult.type === RunResult.Type.IOI && <TextWithAnimation2>{problemResult.score}</TextWithAnimation2>}
</Label>
</Circle>
</ProblemWrap>
Expand Down

0 comments on commit 5739e4b

Please sign in to comment.