mirror of https://github.com/ppy/osu
Update xmldoc and make realm transactions more obvious
This commit is contained in:
parent
4d7fd236c5
commit
c7d0a7dde2
|
@ -41,50 +41,56 @@ public void Queue(Live<BeatmapSetInfo> beatmapSet, MetadataLookupScope lookupSco
|
||||||
updateScheduler);
|
updateScheduler);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Process(BeatmapSetInfo beatmapSet, MetadataLookupScope lookupScope = MetadataLookupScope.LocalCacheFirst) => beatmapSet.Realm!.Write(_ =>
|
public void Process(BeatmapSetInfo beatmapSet, MetadataLookupScope lookupScope = MetadataLookupScope.LocalCacheFirst)
|
||||||
{
|
{
|
||||||
// Before we use below, we want to invalidate.
|
beatmapSet.Realm!.Write(_ =>
|
||||||
workingBeatmapCache.Invalidate(beatmapSet);
|
|
||||||
|
|
||||||
if (lookupScope != MetadataLookupScope.None)
|
|
||||||
metadataLookup.Update(beatmapSet, lookupScope == MetadataLookupScope.OnlineFirst);
|
|
||||||
|
|
||||||
foreach (var beatmap in beatmapSet.Beatmaps)
|
|
||||||
{
|
{
|
||||||
difficultyCache.Invalidate(beatmap);
|
// Before we use below, we want to invalidate.
|
||||||
|
workingBeatmapCache.Invalidate(beatmapSet);
|
||||||
|
|
||||||
var working = workingBeatmapCache.GetWorkingBeatmap(beatmap);
|
if (lookupScope != MetadataLookupScope.None)
|
||||||
var ruleset = working.BeatmapInfo.Ruleset.CreateInstance();
|
metadataLookup.Update(beatmapSet, lookupScope == MetadataLookupScope.OnlineFirst);
|
||||||
|
|
||||||
Debug.Assert(ruleset != null);
|
foreach (var beatmap in beatmapSet.Beatmaps)
|
||||||
|
{
|
||||||
|
difficultyCache.Invalidate(beatmap);
|
||||||
|
|
||||||
var calculator = ruleset.CreateDifficultyCalculator(working);
|
var working = workingBeatmapCache.GetWorkingBeatmap(beatmap);
|
||||||
|
var ruleset = working.BeatmapInfo.Ruleset.CreateInstance();
|
||||||
|
|
||||||
beatmap.StarRating = calculator.Calculate().StarRating;
|
Debug.Assert(ruleset != null);
|
||||||
beatmap.Length = working.Beatmap.CalculatePlayableLength();
|
|
||||||
beatmap.BPM = 60000 / working.Beatmap.GetMostCommonBeatLength();
|
|
||||||
beatmap.EndTimeObjectCount = working.Beatmap.HitObjects.Count(h => h is IHasDuration);
|
|
||||||
beatmap.TotalObjectCount = working.Beatmap.HitObjects.Count;
|
|
||||||
}
|
|
||||||
|
|
||||||
// And invalidate again afterwards as re-fetching the most up-to-date database metadata will be required.
|
var calculator = ruleset.CreateDifficultyCalculator(working);
|
||||||
workingBeatmapCache.Invalidate(beatmapSet);
|
|
||||||
});
|
|
||||||
|
|
||||||
public void ProcessObjectCounts(BeatmapInfo beatmapInfo, MetadataLookupScope lookupScope = MetadataLookupScope.LocalCacheFirst) => beatmapInfo.Realm!.Write(_ =>
|
beatmap.StarRating = calculator.Calculate().StarRating;
|
||||||
|
beatmap.Length = working.Beatmap.CalculatePlayableLength();
|
||||||
|
beatmap.BPM = 60000 / working.Beatmap.GetMostCommonBeatLength();
|
||||||
|
beatmap.EndTimeObjectCount = working.Beatmap.HitObjects.Count(h => h is IHasDuration);
|
||||||
|
beatmap.TotalObjectCount = working.Beatmap.HitObjects.Count;
|
||||||
|
}
|
||||||
|
|
||||||
|
// And invalidate again afterwards as re-fetching the most up-to-date database metadata will be required.
|
||||||
|
workingBeatmapCache.Invalidate(beatmapSet);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ProcessObjectCounts(BeatmapInfo beatmapInfo, MetadataLookupScope lookupScope = MetadataLookupScope.LocalCacheFirst)
|
||||||
{
|
{
|
||||||
// Before we use below, we want to invalidate.
|
beatmapInfo.Realm!.Write(_ =>
|
||||||
workingBeatmapCache.Invalidate(beatmapInfo);
|
{
|
||||||
|
// Before we use below, we want to invalidate.
|
||||||
|
workingBeatmapCache.Invalidate(beatmapInfo);
|
||||||
|
|
||||||
var working = workingBeatmapCache.GetWorkingBeatmap(beatmapInfo);
|
var working = workingBeatmapCache.GetWorkingBeatmap(beatmapInfo);
|
||||||
var beatmap = working.Beatmap;
|
var beatmap = working.Beatmap;
|
||||||
|
|
||||||
beatmapInfo.EndTimeObjectCount = beatmap.HitObjects.Count(h => h is IHasDuration);
|
beatmapInfo.EndTimeObjectCount = beatmap.HitObjects.Count(h => h is IHasDuration);
|
||||||
beatmapInfo.TotalObjectCount = beatmap.HitObjects.Count;
|
beatmapInfo.TotalObjectCount = beatmap.HitObjects.Count;
|
||||||
|
|
||||||
// And invalidate again afterwards as re-fetching the most up-to-date database metadata will be required.
|
// And invalidate again afterwards as re-fetching the most up-to-date database metadata will be required.
|
||||||
workingBeatmapCache.Invalidate(beatmapInfo);
|
workingBeatmapCache.Invalidate(beatmapInfo);
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
#region Implementation of IDisposable
|
#region Implementation of IDisposable
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,11 @@ public interface IBeatmapUpdater : IDisposable
|
||||||
/// <param name="lookupScope">The preferred scope to use for metadata lookup.</param>
|
/// <param name="lookupScope">The preferred scope to use for metadata lookup.</param>
|
||||||
void Process(BeatmapSetInfo beatmapSet, MetadataLookupScope lookupScope = MetadataLookupScope.LocalCacheFirst);
|
void Process(BeatmapSetInfo beatmapSet, MetadataLookupScope lookupScope = MetadataLookupScope.LocalCacheFirst);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Runs a subset of processing focused on updating any cached beatmap object counts.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="beatmapInfo">The managed beatmap to update. A transaction will be opened to apply changes.</param>
|
||||||
|
/// <param name="lookupScope">The preferred scope to use for metadata lookup.</param>
|
||||||
void ProcessObjectCounts(BeatmapInfo beatmapInfo, MetadataLookupScope lookupScope = MetadataLookupScope.LocalCacheFirst);
|
void ProcessObjectCounts(BeatmapInfo beatmapInfo, MetadataLookupScope lookupScope = MetadataLookupScope.LocalCacheFirst);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue