mirror of
https://github.com/ppy/osu
synced 2025-02-21 04:57:11 +00:00
Don't filter away results with missing data when using "Date Submitted" or "Date Ranked" sort modes
From a user's perspective, changing a sort / order mode shouldn't filter away results, but we were doing this. In terms of UX expectations, in stable this kind of scenario would results in a group being added to the end of son select with "Not ranked" or "Unknown". I think we should aim to match this eventually.
This commit is contained in:
parent
29be26b150
commit
82293c0c86
@ -532,15 +532,20 @@ namespace osu.Game.Tests.Visual.SongSelect
|
||||
loadBeatmaps(sets);
|
||||
|
||||
AddStep("Sort by date submitted", () => carousel.Filter(new FilterCriteria { Sort = SortMode.DateSubmitted }, false));
|
||||
checkVisibleItemCount(diff: false, count: 8);
|
||||
checkVisibleItemCount(diff: false, count: 20);
|
||||
checkVisibleItemCount(diff: true, count: 5);
|
||||
|
||||
AddStep("Sort by date submitted and string", () => carousel.Filter(new FilterCriteria
|
||||
{
|
||||
Sort = SortMode.DateSubmitted,
|
||||
SearchText = zzz_string
|
||||
}, false));
|
||||
checkVisibleItemCount(diff: false, count: 3);
|
||||
checkVisibleItemCount(diff: false, count: 5);
|
||||
checkVisibleItemCount(diff: true, count: 5);
|
||||
|
||||
AddAssert("missing date submitted are at end",
|
||||
() => carousel.Items.OfType<DrawableCarouselBeatmapSet>().TakeLast(2).All(i => i.Item is CarouselBeatmapSet s && s.BeatmapSet.DateSubmitted == null));
|
||||
AddAssert("rest are at start", () => carousel.Items.OfType<DrawableCarouselBeatmapSet>().Take(3).All(i => i.Item is CarouselBeatmapSet s && s.BeatmapSet.DateSubmitted != null));
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -1129,7 +1134,7 @@ namespace osu.Game.Tests.Visual.SongSelect
|
||||
{
|
||||
// until step required as we are querying against alive items, which are loaded asynchronously inside DrawableCarouselBeatmapSet.
|
||||
AddUntilStep($"{count} {(diff ? "diffs" : "sets")} visible", () =>
|
||||
carousel.Items.Count(s => (diff ? s.Item is CarouselBeatmap : s.Item is CarouselBeatmapSet) && s.Item.Visible) == count);
|
||||
carousel.Items.Count(s => (diff ? s.Item is CarouselBeatmap : s.Item is CarouselBeatmapSet) && s.Item.Visible), () => Is.EqualTo(count));
|
||||
}
|
||||
|
||||
private void checkSelectionIsCentered()
|
||||
|
@ -61,7 +61,7 @@ namespace osu.Game.Screens.Select.Carousel
|
||||
if (!(other is CarouselBeatmapSet otherSet))
|
||||
return base.CompareTo(criteria, other);
|
||||
|
||||
int comparison = 0;
|
||||
int comparison;
|
||||
|
||||
switch (criteria.Sort)
|
||||
{
|
||||
@ -87,11 +87,7 @@ namespace osu.Game.Screens.Select.Carousel
|
||||
break;
|
||||
|
||||
case SortMode.DateRanked:
|
||||
// Beatmaps which have no ranked date should already be filtered away in this mode.
|
||||
if (BeatmapSet.DateRanked == null || otherSet.BeatmapSet.DateRanked == null)
|
||||
break;
|
||||
|
||||
comparison = otherSet.BeatmapSet.DateRanked.Value.CompareTo(BeatmapSet.DateRanked.Value);
|
||||
comparison = compareNullableDateTimeOffset(BeatmapSet.DateRanked, otherSet.BeatmapSet.DateRanked);
|
||||
break;
|
||||
|
||||
case SortMode.LastPlayed:
|
||||
@ -111,11 +107,7 @@ namespace osu.Game.Screens.Select.Carousel
|
||||
break;
|
||||
|
||||
case SortMode.DateSubmitted:
|
||||
// Beatmaps which have no submitted date should already be filtered away in this mode.
|
||||
if (BeatmapSet.DateSubmitted == null || otherSet.BeatmapSet.DateSubmitted == null)
|
||||
break;
|
||||
|
||||
comparison = otherSet.BeatmapSet.DateSubmitted.Value.CompareTo(BeatmapSet.DateSubmitted.Value);
|
||||
comparison = compareNullableDateTimeOffset(BeatmapSet.DateSubmitted, otherSet.BeatmapSet.DateSubmitted);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -132,6 +124,14 @@ namespace osu.Game.Screens.Select.Carousel
|
||||
return otherSet.BeatmapSet.ID.CompareTo(BeatmapSet.ID);
|
||||
}
|
||||
|
||||
private static int compareNullableDateTimeOffset(DateTimeOffset? x, DateTimeOffset? y)
|
||||
{
|
||||
if (x == null) return 1;
|
||||
if (y == null) return -1;
|
||||
|
||||
return y.Value.CompareTo(x.Value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// All beatmaps which are not filtered and valid for display.
|
||||
/// </summary>
|
||||
@ -153,12 +153,7 @@ namespace osu.Game.Screens.Select.Carousel
|
||||
{
|
||||
base.Filter(criteria);
|
||||
|
||||
bool filtered = Items.All(i => i.Filtered.Value);
|
||||
|
||||
filtered |= criteria.Sort == SortMode.DateRanked && BeatmapSet.DateRanked == null;
|
||||
filtered |= criteria.Sort == SortMode.DateSubmitted && BeatmapSet.DateSubmitted == null;
|
||||
|
||||
Filtered.Value = filtered;
|
||||
Filtered.Value = Items.All(i => i.Filtered.Value);
|
||||
}
|
||||
|
||||
public override string ToString() => BeatmapSet.ToString();
|
||||
|
Loading…
Reference in New Issue
Block a user