-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rework finalization to make it only in emulation and export modes
- Loading branch information
1 parent
90bd7c1
commit 39b3466
Showing
9 changed files
with
49 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
src/cds/src/main/kotlin/org/icpclive/cds/adapters/AutoFinalize.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package org.icpclive.cds.adapters | ||
|
||
import kotlinx.coroutines.flow.* | ||
import org.icpclive.api.ContestStatus | ||
import org.icpclive.cds.ContestUpdate | ||
import org.icpclive.cds.InfoUpdate | ||
import org.icpclive.util.getLogger | ||
|
||
internal object AutoFinalize | ||
|
||
fun Flow<ContestUpdate>.autoFinalize() = withGroupedRuns({ it.result != null }) | ||
.transformWhile { | ||
emit(it.event) | ||
val info = it.infoAfterEvent | ||
if (info?.status == ContestStatus.OVER && !info.cdsSupportsFinalization && it.runs[false].isNullOrEmpty()) { | ||
emit(InfoUpdate(it.infoAfterEvent!!.copy(status = ContestStatus.FINALIZED))) | ||
getLogger(AutoFinalize::class).info("Contest finished. Finalizing.") | ||
false | ||
} else { | ||
true | ||
} | ||
} | ||
|
||
suspend fun Flow<ContestUpdate>.finalContestState() = autoFinalize().contestState().first { it.infoAfterEvent?.status == ContestStatus.FINALIZED } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters