Skip to content

Commit 9013799

Browse files
committed
Add ability to specify where clause in mark-non-preserved command
1 parent 6b1e72c commit 9013799

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ public class MarkNonPreservedScoresCommand
2929
[Option(CommandOptionType.SingleOrNoValue, Template = "-v|--verbose", Description = "Output when a score is preserved too.")]
3030
public bool Verbose { get; set; }
3131

32+
[Option(Description = "Optional where clause", Template = "--where")]
33+
public string Where { get; set; } = "1 = 1";
34+
3235
public async Task<int> OnExecuteAsync(CancellationToken cancellationToken)
3336
{
3437
LegacyDatabaseHelper.RulesetDatabaseInfo databaseInfo = LegacyDatabaseHelper.GetRulesetSpecifics(RulesetId);
@@ -40,7 +43,7 @@ public async Task<int> OnExecuteAsync(CancellationToken cancellationToken)
4043
using (var db = await DatabaseAccess.GetConnectionAsync(cancellationToken))
4144
{
4245
Console.WriteLine("Fetching all users...");
43-
int[] userIds = (await db.QueryAsync<int>($"SELECT `user_id` FROM {databaseInfo.UserStatsTable}")).ToArray();
46+
int[] userIds = (await db.QueryAsync<int>($"SELECT `user_id` FROM {databaseInfo.UserStatsTable} WHERE {Where}")).ToArray();
4447
Console.WriteLine($"Fetched {userIds.Length} users");
4548

4649
foreach (int userId in userIds)
@@ -58,7 +61,8 @@ private async Task processUser(MySqlConnection db, int userId, CancellationToken
5861
rulesetId = RulesetId,
5962
};
6063

61-
IEnumerable<SoloScore> scores = await db.QueryAsync<SoloScore>(new CommandDefinition("SELECT * FROM scores WHERE preserve = 1 AND user_id = @userId AND ruleset_id = @rulesetId", parameters, cancellationToken: cancellationToken));
64+
IEnumerable<SoloScore> scores = await db.QueryAsync<SoloScore>(new CommandDefinition("SELECT * FROM scores WHERE preserve = 1 AND user_id = @userId AND ruleset_id = @rulesetId",
65+
parameters, cancellationToken: cancellationToken));
6266

6367
if (!scores.Any())
6468
return;

0 commit comments

Comments
 (0)