Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Leaderboard breaks on points update #21

Open
TheOriginalSoni opened this issue Feb 12, 2024 · 0 comments
Open

Leaderboard breaks on points update #21

TheOriginalSoni opened this issue Feb 12, 2024 · 0 comments
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@TheOriginalSoni
Copy link
Collaborator

Tried this in the actual DB

UPDATE myus_puzzle U2
SET points = 100
WHERE id=13;

This is supposed to mimic user changing points for one specific puzzle.

However, this breaks the leaderboard query.

SELECT "myus_team"."id", "myus_team"."name", "myus_team"."hunt_id", "myus_team"."creation_time", (SELECT SUM(U2."points") AS "score" FROM "myus_guess" U0 INNER JOIN "myus_puzzle" U2 ON (U0."puzzle_id" = U2."id") WHERE (U0."correct" AND U0."team_id" = ("myus_team"."id")) GROUP BY U2."points") AS "score", COUNT("myus_guess"."id") FILTER (WHERE "myus_guess"."correct") AS "solve_count", (SELECT U0."time" FROM "myus_guess" U0 WHERE (U0."correct" AND U0."team_id" = ("myus_team"."id")) ORDER BY U0."time" DESC LIMIT 1) AS "last_solve" FROM "myus_team" LEFT OUTER JOIN "myus_guess" ON ("myus_team"."id" = "myus_guess"."team_id") WHERE "myus_team"."hunt_id" = 3 GROUP BY "myus_team"."id" ORDER BY 5 DESC, 6 DESC, 7 ASC

and gives more than one row returned by a subquery used as an expression

Understand and fix leaderboard for future

@TheOriginalSoni TheOriginalSoni added bug Something isn't working help wanted Extra attention is needed labels Feb 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant