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

Fix incorrect reporting of user rank in room in case of score ties #241

Merged
merged 1 commit into from
Jul 25, 2024

Conversation

bdach
Copy link
Collaborator

@bdach bdach commented Jul 25, 2024

Should match web, in theory.

Not sure about the CTE usage but it's one row and I'd rather try this than duplicate the subquery.

@bdach bdach requested a review from peppy July 25, 2024 06:34
@bdach bdach self-assigned this Jul 25, 2024
@@ -465,8 +465,10 @@ public async Task<int> GetUserRankInRoomAsync(long roomId, int userId)
var connection = await getConnectionAsync();

return await connection.QuerySingleAsync<int>(
"SELECT COUNT(1) + 1 FROM `multiplayer_rooms_high` WHERE `room_id` = @roomId AND `user_id` != @userId "
+ "AND `total_score` > (SELECT `total_score` FROM `multiplayer_rooms_high` WHERE `room_id` = @roomId AND `user_id` = @userId)",
"WITH `user_score` AS (SELECT `total_score`, `last_score_id` FROM `multiplayer_rooms_high` WHERE `room_id` = @roomId AND `user_id` = @userId) "
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've never used this style of sql before, but have confirmed it works well and I have no prettier ideas.

@peppy peppy merged commit d53d1f8 into ppy:master Jul 25, 2024
2 checks passed
@bdach bdach deleted the fix-daily-challenge-ties branch July 26, 2024 05:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants