Add game-ended notification

Fires the first time a game transitions from non-over to any over-state
(OVER/FINAL/OFF), so the notification lands when the clock runs out
rather than hours later when NHL statisticians stamp OFF. Shows the
winning team's logo with a "{TEAM} wins" title and final score body.

Deduped by game ID via gameEndsSent; cleared on resetForNewDay.
Dev menu: "Test Game Ended Notification" for manual trigger.
This commit is contained in:
2026-04-19 21:38:08 -04:00
parent 89060d7177
commit 18c4ef64d6
3 changed files with 77 additions and 0 deletions
+6
View File
@@ -219,6 +219,12 @@ class MainService: @unchecked Sendable {
notificationManager.notifyGameStarted(game)
}
// Game ended: transition to any over-state (OVER/FINAL/OFF)
if let prevState = previousState, !prevState.isOver, currentState.isOver {
logger.info("Game \(game.id) ended: \(game.awayTeam.abbrev) \(game.awayTeam.score ?? 0)\(game.homeTeam.abbrev) \(game.homeTeam.score ?? 0)")
notificationManager.notifyGameEnded(game)
}
if game.gameType == 3,
let prevState = previousState, !prevState.isOver, currentState.isOver {
hadPlayoffFinalTransition = true