mirror of
https://github.com/ppy/osu.git
synced 2025-01-12 17:23:22 +08:00
Add better log output and sleeping during gameplay sections
This commit is contained in:
parent
57a41c6897
commit
04f48d8862
@ -5,6 +5,7 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
@ -13,6 +14,7 @@ using osu.Framework.Logging;
|
|||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Database;
|
using osu.Game.Database;
|
||||||
using osu.Game.Rulesets;
|
using osu.Game.Rulesets;
|
||||||
|
using osu.Game.Screens.Play;
|
||||||
|
|
||||||
namespace osu.Game
|
namespace osu.Game
|
||||||
{
|
{
|
||||||
@ -30,6 +32,9 @@ namespace osu.Game
|
|||||||
[Resolved]
|
[Resolved]
|
||||||
private IBindable<WorkingBeatmap> gameBeatmap { get; set; } = null!;
|
private IBindable<WorkingBeatmap> gameBeatmap { get; set; } = null!;
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
private ILocalUserPlayInfo? localUserPlayInfo { get; set; }
|
||||||
|
|
||||||
protected override void LoadComplete()
|
protected override void LoadComplete()
|
||||||
{
|
{
|
||||||
base.LoadComplete();
|
base.LoadComplete();
|
||||||
@ -81,10 +86,10 @@ namespace osu.Game
|
|||||||
|
|
||||||
private void processBeatmapSetsWithMissingMetrics()
|
private void processBeatmapSetsWithMissingMetrics()
|
||||||
{
|
{
|
||||||
// TODO: rate limit and pause processing during gameplay.
|
|
||||||
|
|
||||||
HashSet<Guid> beatmapSetIds = new HashSet<Guid>();
|
HashSet<Guid> beatmapSetIds = new HashSet<Guid>();
|
||||||
|
|
||||||
|
Logger.Log("Querying for beatmap sets to reprocess...");
|
||||||
|
|
||||||
realmAccess.Run(r =>
|
realmAccess.Run(r =>
|
||||||
{
|
{
|
||||||
foreach (var b in r.All<BeatmapInfo>().Where(b => b.StarRating == 0 || (b.OnlineID > 0 && b.LastOnlineUpdate == null)))
|
foreach (var b in r.All<BeatmapInfo>().Where(b => b.StarRating == 0 || (b.OnlineID > 0 && b.LastOnlineUpdate == null)))
|
||||||
@ -94,15 +99,25 @@ namespace osu.Game
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Logger.Log($"Found {beatmapSetIds.Count} beatmap sets which require reprocessing.");
|
||||||
|
|
||||||
|
int i = 0;
|
||||||
|
|
||||||
foreach (var id in beatmapSetIds)
|
foreach (var id in beatmapSetIds)
|
||||||
{
|
{
|
||||||
|
while (localUserPlayInfo?.IsPlaying.Value == true)
|
||||||
|
{
|
||||||
|
Logger.Log("Background processing sleeping 30s due to active gameplay...");
|
||||||
|
Thread.Sleep(30000);
|
||||||
|
}
|
||||||
|
|
||||||
realmAccess.Run(r =>
|
realmAccess.Run(r =>
|
||||||
{
|
{
|
||||||
var set = r.Find<BeatmapSetInfo>(id);
|
var set = r.Find<BeatmapSetInfo>(id);
|
||||||
|
|
||||||
if (set != null)
|
if (set != null)
|
||||||
{
|
{
|
||||||
Logger.Log($"Background processing {set}");
|
Logger.Log($"Background processing {set} ({++i} / {beatmapSetIds.Count})");
|
||||||
beatmapUpdater.Process(set);
|
beatmapUpdater.Process(set);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user