Skip to content

Commit

Permalink
Fix poker game list showing wrong pointed counts
Browse files Browse the repository at this point in the history
This fixes #646
  • Loading branch information
StevenWeathers committed Nov 9, 2024
1 parent 027393e commit 2211d5c
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions internal/db/poker/poker.go
Original file line number Diff line number Diff line change
Expand Up @@ -461,8 +461,10 @@ func (d *Service) GetGamesByUser(userID string, limit int, offset int) ([]*thund
)
SELECT p.id, p.name, p.voting_locked, COALESCE(p.active_story_id::text, ''), p.point_values_allowed, p.auto_finish_voting,
p.point_average_rounding, p.created_date, p.updated_date,
CASE WHEN COUNT(s) = 0 THEN '[]'::json ELSE array_to_json(array_agg(row_to_json(s))) END AS stories,
CASE WHEN COUNT(bl) = 0 THEN '[]'::json ELSE array_to_json(array_agg(bl.user_id)) END AS facilitators,
(SELECT CASE WHEN COUNT(s) = 0 THEN '[]'::json ELSE array_to_json(array_agg(row_to_json(s))) END
FROM thunderdome.poker_story s WHERE p.id = s.poker_id) AS stories,
(SELECT CASE WHEN COUNT(bl) = 0 THEN '[]'::json ELSE array_to_json(array_agg(bl.user_id)) END FROM
thunderdome.poker_facilitator bl WHERE bl.poker_id = p.id) AS facilitators,
min(COALESCE(t.name, '')) as team_name, COALESCE(p.team_id::TEXT, ''), p.estimation_scale_id,
COALESCE(
json_build_object(
Expand All @@ -482,8 +484,6 @@ func (d *Service) GetGamesByUser(userID string, limit int, offset int) ([]*thund
'{}'::jsonb
) AS estimation_scale
FROM thunderdome.poker p
LEFT JOIN stories AS s ON s.poker_id = p.id
LEFT JOIN facilitators AS bl ON bl.poker_id = p.id
LEFT JOIN user_teams t ON t.id = p.team_id
LEFT JOIN thunderdome.estimation_scale es ON p.estimation_scale_id = es.id
WHERE p.id IN (SELECT id FROM games)
Expand Down

0 comments on commit 2211d5c

Please sign in to comment.