From a17db321e511c40772e3df473e45202f2c10703f Mon Sep 17 00:00:00 2001 From: 112batuhan Date: Sun, 8 Dec 2024 15:46:01 +0300 Subject: [PATCH] feat: surrealdb sort is broken workaround --- src/database/leaderboard.rs | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/src/database/leaderboard.rs b/src/database/leaderboard.rs index 2db82cc..eeac025 100644 --- a/src/database/leaderboard.rs +++ b/src/database/leaderboard.rs @@ -83,21 +83,24 @@ impl DatabaseClient { .db .query( " - SELECT - beatmap, - count(beatmap) as count + SELECT * FROM ( - ( - SELECT beatmaps - FROM influenced_by - WHERE $ranked_only = false OR <-user.ranked_mapper.at(0) = true + SELECT + beatmap, + count(beatmap) as count + FROM ( + ( + SELECT beatmaps + FROM influenced_by + WHERE $ranked_only = false OR <-user.ranked_mapper.at(0) = true + ) + .map(|$val| $val.values()) + .flatten() + .flatten() + .map(|$val| {beatmap: $val}) ) - .map(|$val| $val.values()) - .flatten() - .flatten() - .map(|$val| {beatmap: $val}) + GROUP BY beatmap ) - GROUP BY beatmap ORDER BY count DESC START $start LIMIT $limit;