This commit is contained in:
Tomas Dvorak
2026-01-26 08:13:18 +01:00
parent aa036b6550
commit dfc079288f
505 changed files with 95755 additions and 5712 deletions
@@ -794,6 +794,8 @@ func (c *ScoreboardController) PutAdmin(ctx *gin.Context) {
s.ExternalMatchID = *payload.ExternalMatchID
}
if payload.Active != nil {
// Active flag is now derived from whether the scoreboard is linked to a match.
// The incoming value is accepted but will be normalized below.
s.Active = *payload.Active
}
if payload.SidesFlipped != nil {
@@ -814,13 +816,16 @@ func (c *ScoreboardController) PutAdmin(ctx *gin.Context) {
s.ElapsedSeconds = parseTimerToSeconds(*payload.Timer)
}
// Derive Active flag: scoreboard is considered active whenever it is linked to a match.
s.Active = strings.TrimSpace(s.ExternalMatchID) != ""
if err := c.DB.Save(s).Error; err != nil {
ctx.JSON(http.StatusInternalServerError, gin.H{"error": "failed to save"})
return
}
// Best-effort: if scoreboard active and linked to a match, write live cache
if s.Active && s.ExternalMatchID != "" {
// Best-effort: if scoreboard is linked to a match, write live cache
if s.ExternalMatchID != "" {
go writeLiveScoreboardCache(s)
}
ctx.JSON(http.StatusOK, s)