mirror of
https://github.com/Dvorinka/MyClubServer.git
synced 2026-06-05 03:02:56 +00:00
hot fix #1
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user