Skip to content

Commit 8a6e664

Browse files
committed
Add support for deleting legacy replays and scores
1 parent 7fd9fec commit 8a6e664

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,9 +142,13 @@ private async Task processPartitionAsync(MySqlConnection db, Amazon.S3.IAmazonS3
142142

143143
if (score.is_legacy_score)
144144
{
145-
// TODO: we likely do want logic here to handle the cleanup of replays.
146-
// for now, make sure we don't attempt to clean up stable scores with replays here.
147-
throw new InvalidOperationException($"Legacy score id:{score.id} legacy_id:{score.legacy_score_id} has replay flag set");
145+
DogStatsd.Increment("legacy_scores_deleted");
146+
var rulesetSpecifics = LegacyDatabaseHelper.GetRulesetSpecifics(score.ruleset_id);
147+
148+
await s3.DeleteObjectAsync(rulesetSpecifics.ReplayBucket, score.legacy_score_id.ToString(), cancellationToken);
149+
150+
await db.ExecuteAsync($"DELETE FROM {rulesetSpecifics.ReplayTable} WHERE score_id = @scoreId", new { scoreId = score.legacy_score_id });
151+
await db.ExecuteAsync($"DELETE FROM {rulesetSpecifics.HighScoreTable} WHERE score_id = @scoreId", new { scoreId = score.legacy_score_id });
148152
}
149153

150154
if (!DryRun)

osu.Server.Queues.ScoreStatisticsProcessor/Helpers/LegacyDatabaseHelper.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ public class RulesetDatabaseInfo
4040
public readonly string LeadersTable;
4141
public readonly string UserStatsTable;
4242
public readonly string ReplayTable;
43+
public readonly string ReplayBucket;
4344
public readonly string LastProcessedPpUserCount;
4445
public readonly string LastProcessedPpScoreCount;
4546
public readonly string TodaysRankColumn;
@@ -60,6 +61,8 @@ public RulesetDatabaseInfo(int rulesetId, string rulesetIdentifier, bool legacyS
6061
LeadersTable = $"`{dbName}`.`osu_leaders{tableSuffix}`";
6162
UserStatsTable = $"`{dbName}`.`osu_user_stats{tableSuffix}`";
6263
ReplayTable = $"`{dbName}`.`osu_replays{tableSuffix}`";
64+
ReplayBucket = $"replay-{rulesetIdentifier}";
65+
6366
LastProcessedPpUserCount = $"pp_last_user_id{tableSuffix}";
6467
LastProcessedPpScoreCount = $"pp_last_score_id{tableSuffix}";
6568
TodaysRankColumn = $"pp_rank_column_{rulesetIdentifier}";

0 commit comments

Comments
 (0)