Sort beatmaps by a preliminary order

This commit is contained in:
Natsu Kagami 2021-02-02 02:29:49 +09:00
parent bd845d9662
commit 99d59b3548
Signed by: nki
GPG key ID: 7306B3D3C3AD6E51

View file

@ -79,13 +79,14 @@ impl BeatmapMetaCache {
.await
}
None => {
let beatmaps = self
let mut beatmaps = self
.client
.beatmaps(crate::BeatmapRequestKind::Beatmapset(id), |f| f)
.await?;
if beatmaps.is_empty() {
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 {
// Save each beatmap.
beatmaps.iter().for_each(|b| {