mirror of
https://github.com/ppy/osu.git
synced 2024-09-22 01:27:29 +08:00
Merge pull request #22775 from peppy/dont-filter-results-on-sort-mode
Don't filter away results with missing data when using "Date Submitted" or "Date Ranked" sort modes
This commit is contained in:
commit
ff59a236ae
@ -516,15 +516,20 @@ namespace osu.Game.Tests.Visual.SongSelect
|
|||||||
{
|
{
|
||||||
sets.Clear();
|
sets.Clear();
|
||||||
|
|
||||||
for (int i = 0; i < 20; i++)
|
for (int i = 0; i < 10; i++)
|
||||||
{
|
{
|
||||||
var set = TestResources.CreateTestBeatmapSetInfo(5);
|
var set = TestResources.CreateTestBeatmapSetInfo(5);
|
||||||
|
|
||||||
if (i >= 2 && i < 10)
|
// A total of 6 sets have date submitted (4 don't)
|
||||||
|
// A total of 5 sets have artist string (3 of which also have date submitted)
|
||||||
|
|
||||||
|
if (i >= 2 && i < 8) // i = 2, 3, 4, 5, 6, 7 have submitted date
|
||||||
set.DateSubmitted = DateTimeOffset.Now.AddMinutes(i);
|
set.DateSubmitted = DateTimeOffset.Now.AddMinutes(i);
|
||||||
if (i < 5)
|
if (i < 5) // i = 0, 1, 2, 3, 4 have matching string
|
||||||
set.Beatmaps.ForEach(b => b.Metadata.Artist = zzz_string);
|
set.Beatmaps.ForEach(b => b.Metadata.Artist = zzz_string);
|
||||||
|
|
||||||
|
set.Beatmaps.ForEach(b => b.Metadata.Title = $"submitted: {set.DateSubmitted}");
|
||||||
|
|
||||||
sets.Add(set);
|
sets.Add(set);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -532,15 +537,26 @@ namespace osu.Game.Tests.Visual.SongSelect
|
|||||||
loadBeatmaps(sets);
|
loadBeatmaps(sets);
|
||||||
|
|
||||||
AddStep("Sort by date submitted", () => carousel.Filter(new FilterCriteria { Sort = SortMode.DateSubmitted }, false));
|
AddStep("Sort by date submitted", () => carousel.Filter(new FilterCriteria { Sort = SortMode.DateSubmitted }, false));
|
||||||
checkVisibleItemCount(diff: false, count: 8);
|
checkVisibleItemCount(diff: false, count: 10);
|
||||||
checkVisibleItemCount(diff: true, count: 5);
|
checkVisibleItemCount(diff: true, count: 5);
|
||||||
|
|
||||||
|
AddAssert("missing date are at end",
|
||||||
|
() => carousel.Items.OfType<DrawableCarouselBeatmapSet>().Reverse().TakeWhile(i => i.Item is CarouselBeatmapSet s && s.BeatmapSet.DateSubmitted == null).Count(), () => Is.EqualTo(4));
|
||||||
|
AddAssert("rest are at start", () => carousel.Items.OfType<DrawableCarouselBeatmapSet>().TakeWhile(i => i.Item is CarouselBeatmapSet s && s.BeatmapSet.DateSubmitted != null).Count(),
|
||||||
|
() => Is.EqualTo(6));
|
||||||
|
|
||||||
AddStep("Sort by date submitted and string", () => carousel.Filter(new FilterCriteria
|
AddStep("Sort by date submitted and string", () => carousel.Filter(new FilterCriteria
|
||||||
{
|
{
|
||||||
Sort = SortMode.DateSubmitted,
|
Sort = SortMode.DateSubmitted,
|
||||||
SearchText = zzz_string
|
SearchText = zzz_string
|
||||||
}, false));
|
}, false));
|
||||||
checkVisibleItemCount(diff: false, count: 3);
|
checkVisibleItemCount(diff: false, count: 5);
|
||||||
checkVisibleItemCount(diff: true, count: 5);
|
checkVisibleItemCount(diff: true, count: 5);
|
||||||
|
|
||||||
|
AddAssert("missing date are at end",
|
||||||
|
() => carousel.Items.OfType<DrawableCarouselBeatmapSet>().Reverse().TakeWhile(i => i.Item is CarouselBeatmapSet s && s.BeatmapSet.DateSubmitted == null).Count(), () => Is.EqualTo(2));
|
||||||
|
AddAssert("rest are at start", () => carousel.Items.OfType<DrawableCarouselBeatmapSet>().TakeWhile(i => i.Item is CarouselBeatmapSet s && s.BeatmapSet.DateSubmitted != null).Count(),
|
||||||
|
() => Is.EqualTo(3));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
@ -1129,7 +1145,7 @@ namespace osu.Game.Tests.Visual.SongSelect
|
|||||||
{
|
{
|
||||||
// until step required as we are querying against alive items, which are loaded asynchronously inside DrawableCarouselBeatmapSet.
|
// until step required as we are querying against alive items, which are loaded asynchronously inside DrawableCarouselBeatmapSet.
|
||||||
AddUntilStep($"{count} {(diff ? "diffs" : "sets")} visible", () =>
|
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()
|
private void checkSelectionIsCentered()
|
||||||
@ -1190,8 +1206,11 @@ namespace osu.Game.Tests.Visual.SongSelect
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
foreach (var item in Scroll.Children)
|
foreach (var item in Scroll.Children.OrderBy(c => c.Y))
|
||||||
{
|
{
|
||||||
|
if (item.Item?.Visible != true)
|
||||||
|
continue;
|
||||||
|
|
||||||
yield return item;
|
yield return item;
|
||||||
|
|
||||||
if (item is DrawableCarouselBeatmapSet set)
|
if (item is DrawableCarouselBeatmapSet set)
|
||||||
|
@ -61,7 +61,7 @@ namespace osu.Game.Screens.Select.Carousel
|
|||||||
if (!(other is CarouselBeatmapSet otherSet))
|
if (!(other is CarouselBeatmapSet otherSet))
|
||||||
return base.CompareTo(criteria, other);
|
return base.CompareTo(criteria, other);
|
||||||
|
|
||||||
int comparison = 0;
|
int comparison;
|
||||||
|
|
||||||
switch (criteria.Sort)
|
switch (criteria.Sort)
|
||||||
{
|
{
|
||||||
@ -87,11 +87,7 @@ namespace osu.Game.Screens.Select.Carousel
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case SortMode.DateRanked:
|
case SortMode.DateRanked:
|
||||||
// Beatmaps which have no ranked date should already be filtered away in this mode.
|
comparison = Nullable.Compare(otherSet.BeatmapSet.DateRanked, BeatmapSet.DateRanked);
|
||||||
if (BeatmapSet.DateRanked == null || otherSet.BeatmapSet.DateRanked == null)
|
|
||||||
break;
|
|
||||||
|
|
||||||
comparison = otherSet.BeatmapSet.DateRanked.Value.CompareTo(BeatmapSet.DateRanked.Value);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SortMode.LastPlayed:
|
case SortMode.LastPlayed:
|
||||||
@ -111,11 +107,7 @@ namespace osu.Game.Screens.Select.Carousel
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case SortMode.DateSubmitted:
|
case SortMode.DateSubmitted:
|
||||||
// Beatmaps which have no submitted date should already be filtered away in this mode.
|
comparison = Nullable.Compare(otherSet.BeatmapSet.DateSubmitted, BeatmapSet.DateSubmitted);
|
||||||
if (BeatmapSet.DateSubmitted == null || otherSet.BeatmapSet.DateSubmitted == null)
|
|
||||||
break;
|
|
||||||
|
|
||||||
comparison = otherSet.BeatmapSet.DateSubmitted.Value.CompareTo(BeatmapSet.DateSubmitted.Value);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -153,12 +145,7 @@ namespace osu.Game.Screens.Select.Carousel
|
|||||||
{
|
{
|
||||||
base.Filter(criteria);
|
base.Filter(criteria);
|
||||||
|
|
||||||
bool filtered = Items.All(i => i.Filtered.Value);
|
Filtered.Value = 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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string ToString() => BeatmapSet.ToString();
|
public override string ToString() => BeatmapSet.ToString();
|
||||||
|
Loading…
Reference in New Issue
Block a user