mirror of
https://github.com/natsukagami/youmubot.git
synced 2025-04-19 16:58:55 +00:00
Sort beatmaps by a preliminary order
This commit is contained in:
parent
bd845d9662
commit
99d59b3548
1 changed files with 2 additions and 1 deletions
|
@ -79,13 +79,14 @@ impl BeatmapMetaCache {
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
None => {
|
None => {
|
||||||
let beatmaps = self
|
let mut beatmaps = self
|
||||||
.client
|
.client
|
||||||
.beatmaps(crate::BeatmapRequestKind::Beatmapset(id), |f| f)
|
.beatmaps(crate::BeatmapRequestKind::Beatmapset(id), |f| f)
|
||||||
.await?;
|
.await?;
|
||||||
if beatmaps.is_empty() {
|
if beatmaps.is_empty() {
|
||||||
return Err(Error::msg("beatmapset not found"));
|
return Err(Error::msg("beatmapset not found"));
|
||||||
}
|
}
|
||||||
|
beatmaps.sort_by_key(|b| (b.mode as u8, (b.difficulty.stars * 1000.0) as u64)); // Cast so that Ord is maintained
|
||||||
if let ApprovalStatus::Ranked(_) = &beatmaps[0].approval {
|
if let ApprovalStatus::Ranked(_) = &beatmaps[0].approval {
|
||||||
// Save each beatmap.
|
// Save each beatmap.
|
||||||
beatmaps.iter().for_each(|b| {
|
beatmaps.iter().for_each(|b| {
|
||||||
|
|
Loading…
Add table
Reference in a new issue