Skip to content

Commit b9110e9

Browse files
committed
refactor: reverse osg order when sorted by rank
1 parent 62555a1 commit b9110e9

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

bathbot-model/src/osu_stats.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,7 @@ pub struct OsuStatsListParams {
466466
pub rank_max: usize,
467467
}
468468

469-
#[derive(Copy, Clone, CreateOption, CommandOption, Debug)]
469+
#[derive(Copy, Clone, CreateOption, CommandOption, Debug, PartialEq, Eq)]
470470
pub enum OsuStatsScoresOrder {
471471
#[option(name = "Accuracy", value = "acc")]
472472
Acc = 3,

bathbot/src/commands/osu/osustats/globals.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -290,15 +290,22 @@ impl<'m> OsuStatsScores<'m> {
290290
) -> OsuStatsParams {
291291
let mut params = OsuStatsParams::new(username);
292292

293+
let order = self.sort.unwrap_or_default();
294+
let mut descending = self.reverse.map_or(true, bool::not);
295+
296+
if order == OsuStatsScoresOrder::Rank {
297+
descending = !descending;
298+
}
299+
293300
params
294301
.mode(mode)
295302
.page(1)
296303
.min_rank(self.min_rank.unwrap_or(Self::MIN_RANK) as usize)
297304
.max_rank(self.max_rank.unwrap_or(Self::MAX_RANK) as usize)
298305
.min_acc(self.min_acc.unwrap_or(0.0))
299306
.max_acc(self.max_acc.unwrap_or(100.0))
300-
.order(self.sort.unwrap_or_default())
301-
.descending(self.reverse.map_or(true, bool::not));
307+
.order(order)
308+
.descending(descending);
302309

303310
if let Some(mods) = mods {
304311
params.mods(mods);

0 commit comments

Comments
 (0)