mirror of
https://github.com/ppy/osu.git
synced 2025-01-12 16:43:00 +08:00
Add migration
This commit is contained in:
parent
4eba3b5d70
commit
644e7d6fe6
@ -73,6 +73,7 @@ namespace osu.Game.Database
|
|||||||
processBeatmapsWithMissingObjectCounts();
|
processBeatmapsWithMissingObjectCounts();
|
||||||
processScoresWithMissingStatistics();
|
processScoresWithMissingStatistics();
|
||||||
convertLegacyTotalScoreToStandardised();
|
convertLegacyTotalScoreToStandardised();
|
||||||
|
upgradeScoreRanks();
|
||||||
}, TaskCreationOptions.LongRunning).ContinueWith(t =>
|
}, TaskCreationOptions.LongRunning).ContinueWith(t =>
|
||||||
{
|
{
|
||||||
if (t.Exception?.InnerException is ObjectDisposedException)
|
if (t.Exception?.InnerException is ObjectDisposedException)
|
||||||
@ -354,6 +355,7 @@ namespace osu.Game.Database
|
|||||||
realmAccess.Write(r =>
|
realmAccess.Write(r =>
|
||||||
{
|
{
|
||||||
ScoreInfo s = r.Find<ScoreInfo>(id)!;
|
ScoreInfo s = r.Find<ScoreInfo>(id)!;
|
||||||
|
// TODO: ensure that this is also updating rank (as it will set TotalScoreVersion to latest).
|
||||||
StandardisedScoreMigrationTools.UpdateFromLegacy(s, beatmapManager);
|
StandardisedScoreMigrationTools.UpdateFromLegacy(s, beatmapManager);
|
||||||
s.TotalScoreVersion = LegacyScoreEncoder.LATEST_VERSION;
|
s.TotalScoreVersion = LegacyScoreEncoder.LATEST_VERSION;
|
||||||
});
|
});
|
||||||
@ -375,6 +377,62 @@ namespace osu.Game.Database
|
|||||||
completeNotification(notification, processedCount, scoreIds.Count, failedCount);
|
completeNotification(notification, processedCount, scoreIds.Count, failedCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void upgradeScoreRanks()
|
||||||
|
{
|
||||||
|
Logger.Log("Querying for scores that need rank upgrades...");
|
||||||
|
|
||||||
|
HashSet<Guid> scoreIds = realmAccess.Run(r => new HashSet<Guid>(
|
||||||
|
r.All<ScoreInfo>()
|
||||||
|
.Where(s => s.TotalScoreVersion < LegacyScoreEncoder.LATEST_VERSION)
|
||||||
|
.Select(s => s.ID)));
|
||||||
|
|
||||||
|
Logger.Log($"Found {scoreIds.Count} scores which require rank upgrades.");
|
||||||
|
|
||||||
|
if (scoreIds.Count == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var notification = showProgressNotification(scoreIds.Count, "Adjusting ranks of scores", "scores now have more correct ranks");
|
||||||
|
|
||||||
|
int processedCount = 0;
|
||||||
|
int failedCount = 0;
|
||||||
|
|
||||||
|
foreach (var id in scoreIds)
|
||||||
|
{
|
||||||
|
if (notification?.State == ProgressNotificationState.Cancelled)
|
||||||
|
break;
|
||||||
|
|
||||||
|
updateNotificationProgress(notification, processedCount, scoreIds.Count);
|
||||||
|
|
||||||
|
sleepIfRequired();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// Can't use async overload because we're not on the update thread.
|
||||||
|
// ReSharper disable once MethodHasAsyncOverload
|
||||||
|
realmAccess.Write(r =>
|
||||||
|
{
|
||||||
|
ScoreInfo s = r.Find<ScoreInfo>(id)!;
|
||||||
|
// TODO: uncomment when ready
|
||||||
|
// s.Rank = StandardisedScoreMigrationTools.ComputeRank(s, beatmapManager);
|
||||||
|
});
|
||||||
|
|
||||||
|
++processedCount;
|
||||||
|
}
|
||||||
|
catch (ObjectDisposedException)
|
||||||
|
{
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Logger.Log($"Failed to update rank score {id}: {e}");
|
||||||
|
realmAccess.Write(r => r.Find<ScoreInfo>(id)!.BackgroundReprocessingFailed = true);
|
||||||
|
++failedCount;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
completeNotification(notification, processedCount, scoreIds.Count, failedCount);
|
||||||
|
}
|
||||||
|
|
||||||
private void updateNotificationProgress(ProgressNotification? notification, int processedCount, int totalCount)
|
private void updateNotificationProgress(ProgressNotification? notification, int processedCount, int totalCount)
|
||||||
{
|
{
|
||||||
if (notification == null)
|
if (notification == null)
|
||||||
|
@ -43,9 +43,10 @@ namespace osu.Game.Scoring.Legacy
|
|||||||
/// 30000012: Fix incorrect total score conversion on selected beatmaps after implementing the more correct
|
/// 30000012: Fix incorrect total score conversion on selected beatmaps after implementing the more correct
|
||||||
/// <see cref="LegacyRulesetExtensions.CalculateDifficultyPeppyStars"/> method. Reconvert all scores.
|
/// <see cref="LegacyRulesetExtensions.CalculateDifficultyPeppyStars"/> method. Reconvert all scores.
|
||||||
/// </description></item>
|
/// </description></item>
|
||||||
|
/// <item><description>30000013: All local scores will use lazer definitions of ranks for consistency. Recalculates the rank of all scores.</description></item>
|
||||||
/// </list>
|
/// </list>
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public const int LATEST_VERSION = 30000012;
|
public const int LATEST_VERSION = 30000013;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The first stable-compatible YYYYMMDD format version given to lazer usage of replays.
|
/// The first stable-compatible YYYYMMDD format version given to lazer usage of replays.
|
||||||
|
Loading…
Reference in New Issue
Block a user