Skip to content

Commit

Permalink
Add arbitrary WHERE support for pumping scores
Browse files Browse the repository at this point in the history
  • Loading branch information
peppy committed Nov 12, 2024
1 parent 1c0a695 commit 62a9358
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion osu.ElasticIndexer/Commands/Queue/PumpAllScoresCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ public class PumpAllScoresCommand
[Option("--switch", Description = "Update the configured schema in redis after completing.")]
public bool Switch { get; set; }

[Option(Description = "Optional where clause", Template = "--where")]
public string Where { get; set; } = "1 = 1";

[Option("--include-unranked", Description = "Pump scores with ranked flag set to false to trigger deletion")]
public bool IncludeUnranked { get; set; }

Expand Down Expand Up @@ -69,7 +72,7 @@ public int OnExecute(CancellationToken cancellationToken)
using (var mySqlConnection = processor.GetDatabaseConnection())

{
var chunks = ElasticModel.Chunk<Score>(mySqlConnection, "preserve = 1 " + (IncludeUnranked ? string.Empty : "AND ranked = 1"), AppSettings.BatchSize, from);
var chunks = ElasticModel.Chunk<Score>(mySqlConnection, "preserve = 1 " + (IncludeUnranked ? string.Empty : "AND ranked = 1") + $" AND {Where}", AppSettings.BatchSize, from);
Score? last = null;

foreach (var scores in chunks)
Expand Down

0 comments on commit 62a9358

Please sign in to comment.