mirror of
https://github.com/ppy/osu.git
synced 2025-01-26 12:45:09 +08:00
Assign missing UserID to RealmUser
This commit is contained in:
parent
315a73fb1b
commit
10d6027c89
@ -272,7 +272,7 @@ namespace osu.Game
|
||||
dependencies.Cache(difficultyCache = new BeatmapDifficultyCache());
|
||||
|
||||
// ordering is important here to ensure foreign keys rules are not broken in ModelStore.Cleanup()
|
||||
dependencies.Cache(ScoreManager = new ScoreManager(RulesetStore, () => BeatmapManager, Storage, realm, Scheduler, difficultyCache, LocalConfig));
|
||||
dependencies.Cache(ScoreManager = new ScoreManager(RulesetStore, () => BeatmapManager, Storage, realm, Scheduler, API, difficultyCache, LocalConfig));
|
||||
|
||||
dependencies.Cache(BeatmapManager = new BeatmapManager(Storage, realm, RulesetStore, API, Audio, Resources, Host, defaultBeatmap, difficultyCache, performOnlineLookups: true));
|
||||
|
||||
|
@ -8,11 +8,15 @@ using System.Threading;
|
||||
using Newtonsoft.Json;
|
||||
using osu.Framework.Logging;
|
||||
using osu.Framework.Platform;
|
||||
using osu.Game.Models;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Database;
|
||||
using osu.Game.IO.Archives;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Scoring.Legacy;
|
||||
using osu.Game.Online.API;
|
||||
using osu.Game.Online.API.Requests;
|
||||
using osu.Game.Online.API.Requests.Responses;
|
||||
using Realms;
|
||||
|
||||
namespace osu.Game.Scoring
|
||||
@ -26,11 +30,14 @@ namespace osu.Game.Scoring
|
||||
private readonly RulesetStore rulesets;
|
||||
private readonly Func<BeatmapManager> beatmaps;
|
||||
|
||||
public ScoreImporter(RulesetStore rulesets, Func<BeatmapManager> beatmaps, Storage storage, RealmAccess realm)
|
||||
private readonly IAPIProvider api;
|
||||
|
||||
public ScoreImporter(RulesetStore rulesets, Func<BeatmapManager> beatmaps, Storage storage, RealmAccess realm, IAPIProvider api)
|
||||
: base(storage, realm)
|
||||
{
|
||||
this.rulesets = rulesets;
|
||||
this.beatmaps = beatmaps;
|
||||
this.api = api;
|
||||
}
|
||||
|
||||
protected override ScoreInfo? CreateModel(ArchiveReader archive)
|
||||
@ -68,5 +75,24 @@ namespace osu.Game.Scoring
|
||||
if (string.IsNullOrEmpty(model.StatisticsJson))
|
||||
model.StatisticsJson = JsonConvert.SerializeObject(model.Statistics);
|
||||
}
|
||||
|
||||
protected override void PostImport(ScoreInfo model, Realm realm)
|
||||
{
|
||||
base.PostImport(model, realm);
|
||||
|
||||
var userRequest = new GetUserRequest(model.User.Username);
|
||||
api.Perform(userRequest);
|
||||
APIUser userReq = userRequest.Response;
|
||||
|
||||
if (!(userReq is null)) {
|
||||
Logger.Log($"Assignning UserID to RealmUser");
|
||||
var user = new RealmUser
|
||||
{
|
||||
OnlineID = userReq.Id,
|
||||
Username = model.User.Username
|
||||
};
|
||||
model.RealmUser = user;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -21,6 +21,7 @@ using osu.Game.IO.Archives;
|
||||
using osu.Game.Overlays.Notifications;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
using osu.Game.Online.API;
|
||||
|
||||
namespace osu.Game.Scoring
|
||||
{
|
||||
@ -31,7 +32,7 @@ namespace osu.Game.Scoring
|
||||
private readonly OsuConfigManager configManager;
|
||||
private readonly ScoreImporter scoreImporter;
|
||||
|
||||
public ScoreManager(RulesetStore rulesets, Func<BeatmapManager> beatmaps, Storage storage, RealmAccess realm, Scheduler scheduler,
|
||||
public ScoreManager(RulesetStore rulesets, Func<BeatmapManager> beatmaps, Storage storage, RealmAccess realm, Scheduler scheduler, IAPIProvider api,
|
||||
BeatmapDifficultyCache difficultyCache = null, OsuConfigManager configManager = null)
|
||||
: base(storage, realm)
|
||||
{
|
||||
@ -39,7 +40,7 @@ namespace osu.Game.Scoring
|
||||
this.difficultyCache = difficultyCache;
|
||||
this.configManager = configManager;
|
||||
|
||||
scoreImporter = new ScoreImporter(rulesets, beatmaps, storage, realm)
|
||||
scoreImporter = new ScoreImporter(rulesets, beatmaps, storage, realm, api)
|
||||
{
|
||||
PostNotification = obj => PostNotification?.Invoke(obj)
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user