Skip to content
Snippets Groups Projects
Unverified Commit 1d40ad03 authored by Dean Herbert's avatar Dean Herbert Committed by GitHub
Browse files

Merge pull request #11049 from nanaya/beatmap-state-score-reset

Update ranked flag to remove scores from index
parents 792996dd 971fab97
No related branches found
No related merge requests found
......@@ -11,7 +11,6 @@ use App\Libraries\Search\ScoreSearch;
use App\Models\Beatmap;
use App\Models\Beatmapset;
use App\Models\Solo\Score;
use DB;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Database\Eloquent\Collection;
......@@ -59,15 +58,7 @@ class RemoveBeatmapsetSoloScores implements ShouldQueue
{
$ids = $scores->pluck('id')->all();
$scoresQuery = Score::whereKey($ids);
// Queue delete ahead of time in case process is stopped right after
// db delete is committed. It's fine queuing deleted score ahead of
// time as best score check doesn't use index.
// Set the flag first so indexer will correctly delete it.
$scoresQuery->update(['preserve' => false]);
Score::whereKey($ids)->update(['ranked' => false]);
$this->scoreSearch->queueForIndex($this->schemas, $ids);
DB::transaction(function () use ($ids, $scoresQuery): void {
$scoresQuery->delete();
});
}
}
......@@ -164,6 +164,7 @@ class Score extends Model implements Traits\ReportableInterface
{
return $query
->where('preserve', true)
->where('ranked', true)
->whereHas('user', fn (Builder $q): Builder => $q->default());
}
......
......@@ -47,7 +47,7 @@ class RemoveBeatmapsetSoloScoresTest extends TestCase
$this->createScore($beatmapset);
}
$this->expectCountChange(fn () => Score::count(), count($scores) * -2, 'removes scores');
$this->expectCountChange(fn () => Score::indexable()->count(), count($scores) * -2, 'removes scores');
static::reindexScores();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment