Skip to content

Commit 8e20b67

Browse files
committed
Show intial total users and adjust batching output to be cleaner
1 parent dac2aa7 commit 8e20b67

1 file changed

Lines changed: 10 additions & 6 deletions

File tree

osu.Server.Queues.ScoreStatisticsProcessor/Commands/Maintenance/MarkNonPreservedScoresCommand.cs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,36 +53,40 @@ public async Task<int> OnExecuteAsync(CancellationToken cancellationToken)
5353

5454
LegacyDatabaseHelper.RulesetDatabaseInfo databaseInfo = LegacyDatabaseHelper.GetRulesetSpecifics(RulesetId);
5555

56-
Console.WriteLine($"Running for ruleset {RulesetId}");
56+
Console.WriteLine($"Running against {databaseInfo.UserStatsTable}");
5757
if (DryRun)
5858
Console.WriteLine("RUNNING IN DRY RUN MODE.");
5959

6060
using var db = await DatabaseAccess.GetConnectionAsync(cancellationToken);
6161

62-
const int users_per_fetch = 1000;
62+
const int users_per_fetch = 10000;
63+
64+
int totalCount = await db.QuerySingleAsync<int>($"SELECT COUNT(*) FROM {databaseInfo.UserStatsTable} WHERE {Where}");
65+
Console.WriteLine($"Processing a total of {totalCount} users");
6366

6467
int lastUserId = 0;
6568
int totalUsersProcessed = 0;
6669

6770
while (!cancellationToken.IsCancellationRequested)
6871
{
69-
Console.WriteLine("Fetching more users...");
72+
if (lastUserId > 0)
73+
Console.WriteLine($"Continuing processing starting from user_id {lastUserId}...");
7074

7175
int[] userIds =
7276
(await db.QueryAsync<int>($"SELECT `user_id` FROM {databaseInfo.UserStatsTable} WHERE {Where} AND user_id > {lastUserId} ORDER BY user_id LIMIT {users_per_fetch}")).ToArray();
7377

7478
if (userIds.Length == 0)
7579
break;
7680

77-
Console.WriteLine($"Fetched {userIds.Length} users");
81+
if (Verbose) Console.WriteLine($"Fetched {userIds.Length} users");
7882

7983
for (int i = 0; i < userIds.Length; i++)
8084
{
8185
int userId = userIds[i];
8286

8387
await processUser(db, userId, cancellationToken);
8488

85-
if (i > 0 && i % 100 == 0)
89+
if (i > 0 && i % 1000 == 0)
8690
Console.WriteLine($"Processed {i:N0} of {userIds.Length:N0} users ({totalMarked:N0} marked)");
8791

8892
lastUserId = userId;
@@ -156,7 +160,7 @@ STRAIGHT_JOIN scores s FORCE INDEX (beatmap_user_index)
156160
if (Verbose) Console.WriteLine("Fetching multiplayer scores..");
157161
IEnumerable<ulong> multiplayerScores = db.Query<ulong>("SELECT score_id FROM multiplayer_playlist_item_scores WHERE user_id = @userId", parameters).ToHashSet();
158162

159-
Console.WriteLine($"Processing user {userId} ({scores.Count()} scores)..");
163+
if (Verbose) Console.WriteLine($"Processing user {userId} ({scores.Count()} scores)..");
160164

161165
foreach (var score in scores)
162166
{

0 commit comments

Comments
 (0)