diff --git a/server/db/sql_queries.sql b/server/db/sql_queries.sql index 5217b00..5e1376e 100644 --- a/server/db/sql_queries.sql +++ b/server/db/sql_queries.sql @@ -51,7 +51,7 @@ SELECT team_name, SUM(points) AS points ORDER BY COALESCE(SUM(points), 0) DESC; -- name: TeamPointsEach :many -SELECT team_name, reason, points +SELECT team_name, reason, SUM(points) AS points FROM team_points GROUP BY team_name, reason; diff --git a/server/db/sql_queries.sql.go b/server/db/sql_queries.sql.go index 5c79abe..8732711 100644 --- a/server/db/sql_queries.sql.go +++ b/server/db/sql_queries.sql.go @@ -598,7 +598,7 @@ func (q *Queries) TeamInviteCode(ctx context.Context, teamName string) (string, } const teamPointsEach = `-- name: TeamPointsEach :many -SELECT team_name, reason, points +SELECT team_name, reason, SUM(points) AS points FROM team_points GROUP BY team_name, reason ` @@ -606,7 +606,7 @@ SELECT team_name, reason, points type TeamPointsEachRow struct { TeamName string Reason string - Points float64 + Points sql.NullFloat64 } func (q *Queries) TeamPointsEach(ctx context.Context) ([]TeamPointsEachRow, error) { diff --git a/server/r_leaderboard.go b/server/r_leaderboard.go index 7a243db..143971f 100644 --- a/server/r_leaderboard.go +++ b/server/r_leaderboard.go @@ -101,7 +101,7 @@ func (s *Server) leaderboard(w http.ResponseWriter, r *http.Request) { } table.TeamPoints[ti] = append(table.TeamPoints[ti], teamPoints{ Reason: row.Reason, - Points: row.Points, + Points: row.Points.Float64, }) }