diff --git a/db/queries/infractions.sql b/db/queries/infractions.sql index 8a5af50..8de6e1a 100644 --- a/db/queries/infractions.sql +++ b/db/queries/infractions.sql @@ -19,7 +19,7 @@ WHERE id = $1; SELECT id, game_id, game_card_id, accused, accuser, created, active, affirmed FROM infractions WHERE game_id = $1 -ORDER BY created DESC; +ORDER BY created ASC; -- name: InfractionsActiveCount :one SELECT COUNT(*) FROM infractions diff --git a/db/sqlc/infractions.sql.go b/db/sqlc/infractions.sql.go index edade22..d6758a6 100644 --- a/db/sqlc/infractions.sql.go +++ b/db/sqlc/infractions.sql.go @@ -95,7 +95,7 @@ const infractionsByGame = `-- name: InfractionsByGame :many SELECT id, game_id, game_card_id, accused, accuser, created, active, affirmed FROM infractions WHERE game_id = $1 -ORDER BY created DESC +ORDER BY created ASC ` func (q *Queries) InfractionsByGame(ctx context.Context, gameID string) ([]Infractions, error) { diff --git a/game.go b/game.go index 3920f13..3c85280 100644 --- a/game.go +++ b/game.go @@ -313,6 +313,12 @@ func dataHandler(w http.ResponseWriter, r *http.Request) { w.WriteHeader(http.StatusNoContent) return } + activeCount := 0 + for _, inf := range state.Infractions { + if inf.Active.Bool { + activeCount++ + } + } for _, inf := range state.Infractions { if inf.Active.Bool { log.Debug("serving infraction to host", "infraction_id", inf.ID) @@ -334,9 +340,10 @@ func dataHandler(w http.ResponseWriter, r *http.Request) { } w.Header().Set("Content-Type", "application/json") json.NewEncoder(w).Encode(map[string]any{ - "id": inf.ID, - "accused": accusedName, - "rule": ruleContent, + "id": inf.ID, + "accused": accusedName, + "rule": ruleContent, + "remaining": activeCount - 1, }) return } diff --git a/static/css/style.css b/static/css/style.css index f65fb4d..51de64a 100644 --- a/static/css/style.css +++ b/static/css/style.css @@ -694,6 +694,13 @@ dialog::backdrop { background: var(--color-backdrop); } +.decide-remaining { + text-align: center; + font-size: 0.875em; + color: var(--color-dim); + margin: -0.5em 0 0; +} + .decide-info-rule { font-family: var(--font-script); } diff --git a/static/html/tmpl.game.html b/static/html/tmpl.game.html index b325ee7..e28a3b8 100644 --- a/static/html/tmpl.game.html +++ b/static/html/tmpl.game.html @@ -103,6 +103,7 @@