mirror of
https://github.com/ppy/osu.git
synced 2025-01-28 05:22:54 +08:00
Update realm queries to use Filter
to allow for indirect property filtering
This commit is contained in:
parent
8461eaab46
commit
de3a338d02
@ -13,6 +13,7 @@ using osu.Game.Online.API;
|
|||||||
using osu.Game.Online.Leaderboards;
|
using osu.Game.Online.Leaderboards;
|
||||||
using osu.Game.Rulesets;
|
using osu.Game.Rulesets;
|
||||||
using osu.Game.Scoring;
|
using osu.Game.Scoring;
|
||||||
|
using Realms;
|
||||||
|
|
||||||
namespace osu.Game.Screens.Select.Carousel
|
namespace osu.Game.Screens.Select.Carousel
|
||||||
{
|
{
|
||||||
@ -47,13 +48,15 @@ namespace osu.Game.Screens.Select.Carousel
|
|||||||
{
|
{
|
||||||
base.LoadComplete();
|
base.LoadComplete();
|
||||||
|
|
||||||
scoreSubscription = realmFactory.Context.All<ScoreInfo>().Where(s => s.BeatmapInfo.ID == beatmapInfo.ID).QueryAsyncWithNotifications((_, changes, ___) =>
|
scoreSubscription = realmFactory.Context.All<ScoreInfo>()
|
||||||
{
|
.Filter($"{nameof(ScoreInfo.Beatmap)}.{nameof(BeatmapInfo.ID)} = $0", beatmapInfo.ID)
|
||||||
if (changes == null)
|
.QueryAsyncWithNotifications((_, changes, ___) =>
|
||||||
return;
|
{
|
||||||
|
if (changes == null)
|
||||||
|
return;
|
||||||
|
|
||||||
fetchTopScoreRank();
|
fetchTopScoreRank();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private IDisposable scoreSubscription;
|
private IDisposable scoreSubscription;
|
||||||
@ -84,7 +87,10 @@ namespace osu.Game.Screens.Select.Carousel
|
|||||||
|
|
||||||
using (var realm = realmFactory.CreateContext())
|
using (var realm = realmFactory.CreateContext())
|
||||||
{
|
{
|
||||||
return realm.All<ScoreInfo>().Where(s => s.UserID == api.LocalUser.Value.Id && s.BeatmapInfoID == beatmapInfo.ID && s.RulesetID == ruleset.Value.ID && !s.DeletePending)
|
return realm.All<ScoreInfo>()
|
||||||
|
.AsEnumerable()
|
||||||
|
// TODO: update to use a realm filter directly (or at least figure out the beatmap part to reduce scope).
|
||||||
|
.Where(s => s.UserID == api.LocalUser.Value.Id && s.BeatmapInfoID == beatmapInfo.ID && s.RulesetID == ruleset.Value.ID && !s.DeletePending)
|
||||||
.OrderByDescending(s => s.TotalScore)
|
.OrderByDescending(s => s.TotalScore)
|
||||||
.FirstOrDefault()
|
.FirstOrDefault()
|
||||||
?.Rank;
|
?.Rank;
|
||||||
|
@ -17,6 +17,7 @@ using osu.Game.Online.Leaderboards;
|
|||||||
using osu.Game.Rulesets;
|
using osu.Game.Rulesets;
|
||||||
using osu.Game.Rulesets.Mods;
|
using osu.Game.Rulesets.Mods;
|
||||||
using osu.Game.Scoring;
|
using osu.Game.Scoring;
|
||||||
|
using Realms;
|
||||||
|
|
||||||
namespace osu.Game.Screens.Select.Leaderboards
|
namespace osu.Game.Screens.Select.Leaderboards
|
||||||
{
|
{
|
||||||
@ -80,9 +81,6 @@ namespace osu.Game.Screens.Select.Leaderboards
|
|||||||
[Resolved]
|
[Resolved]
|
||||||
private IAPIProvider api { get; set; }
|
private IAPIProvider api { get; set; }
|
||||||
|
|
||||||
[Resolved]
|
|
||||||
private RealmContextFactory realmContextFactory { get; set; }
|
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load()
|
private void load()
|
||||||
{
|
{
|
||||||
@ -111,13 +109,15 @@ namespace osu.Game.Screens.Select.Leaderboards
|
|||||||
if (beatmapInfo == null)
|
if (beatmapInfo == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
scoreSubscription = realmContextFactory.Context.All<ScoreInfo>().Where(s => s.BeatmapInfo.ID == beatmapInfo.ID).QueryAsyncWithNotifications((_, changes, ___) =>
|
scoreSubscription = realmFactory.Context.All<ScoreInfo>()
|
||||||
{
|
.Filter($"{nameof(ScoreInfo.Beatmap)}.{nameof(BeatmapInfo.ID)} = $0", beatmapInfo.ID)
|
||||||
if (changes == null)
|
.QueryAsyncWithNotifications((_, changes, ___) =>
|
||||||
return;
|
{
|
||||||
|
if (changes == null)
|
||||||
|
return;
|
||||||
|
|
||||||
RefreshScores();
|
RefreshScores();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void Reset()
|
protected override void Reset()
|
||||||
|
Loading…
Reference in New Issue
Block a user