Skip to content

Commit 1d40ad0

Browse files
authored
Merge pull request #11049 from nanaya/beatmap-state-score-reset
Update ranked flag to remove scores from index
2 parents 792996d + 971fab9 commit 1d40ad0

File tree

3 files changed

+3
-11
lines changed

3 files changed

+3
-11
lines changed

app/Jobs/RemoveBeatmapsetSoloScores.php

+1-10
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
use App\Models\Beatmap;
1212
use App\Models\Beatmapset;
1313
use App\Models\Solo\Score;
14-
use DB;
1514
use Illuminate\Bus\Queueable;
1615
use Illuminate\Contracts\Queue\ShouldQueue;
1716
use Illuminate\Database\Eloquent\Collection;
@@ -59,15 +58,7 @@ private function deleteScores(Collection $scores): void
5958
{
6059
$ids = $scores->pluck('id')->all();
6160

62-
$scoresQuery = Score::whereKey($ids);
63-
// Queue delete ahead of time in case process is stopped right after
64-
// db delete is committed. It's fine queuing deleted score ahead of
65-
// time as best score check doesn't use index.
66-
// Set the flag first so indexer will correctly delete it.
67-
$scoresQuery->update(['preserve' => false]);
61+
Score::whereKey($ids)->update(['ranked' => false]);
6862
$this->scoreSearch->queueForIndex($this->schemas, $ids);
69-
DB::transaction(function () use ($ids, $scoresQuery): void {
70-
$scoresQuery->delete();
71-
});
7263
}
7364
}

app/Models/Solo/Score.php

+1
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ public function scopeIndexable(Builder $query): Builder
164164
{
165165
return $query
166166
->where('preserve', true)
167+
->where('ranked', true)
167168
->whereHas('user', fn (Builder $q): Builder => $q->default());
168169
}
169170

tests/Jobs/RemoveBeatmapsetSoloScoresTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public function testHandle()
4747
$this->createScore($beatmapset);
4848
}
4949

50-
$this->expectCountChange(fn () => Score::count(), count($scores) * -2, 'removes scores');
50+
$this->expectCountChange(fn () => Score::indexable()->count(), count($scores) * -2, 'removes scores');
5151

5252
static::reindexScores();
5353

0 commit comments

Comments
 (0)