feat: implement clock expiry scanning and handling for game records #53

Merged
Janis merged 2 commits from NCS-85 into main 2026-05-16 13:24:49 +02:00
2 changed files with 7 additions and 5 deletions
Showing only changes of commit fcd7c80169 - Show all commits
@@ -26,10 +26,11 @@ class GameRedisPublisher(
) extends Observer:
def emitInitialWriteback(): Unit =
try registry.get(gameId).foreach { entry =>
val dto = GameDtoMapper.toGameStateDto(entry, ioClient)
writebackEmit(objectMapper.writeValueAsString(buildWriteback(entry, dto)))
}
try
registry.get(gameId).foreach { entry =>
val dto = GameDtoMapper.toGameStateDto(entry, ioClient)
writebackEmit(objectMapper.writeValueAsString(buildWriteback(entry, dto)))
}
catch case ex: Exception => GameRedisPublisher.log.warnf(ex, "Failed to emit initial writeback for game %s", gameId)
def onGameEvent(event: GameEvent): Unit =
@@ -42,7 +42,8 @@ class GameRecordRepository:
.asScala
.toList
.filter { g =>
val remaining = if g.clockActiveColor == "white" then g.whiteRemainingMs.longValue else g.blackRemainingMs.longValue
val remaining =
if g.clockActiveColor == "white" then g.whiteRemainingMs.longValue else g.blackRemainingMs.longValue
g.clockLastTickAt.longValue + remaining < nowMs
}