Skip to content

Commit

Permalink
Merge pull request #11823 from nanaya/contest-bestof-variant
Browse files Browse the repository at this point in the history
Support ruleset variants in "best of" contests
  • Loading branch information
notbakaneko authored Jan 28, 2025
2 parents f4646be + 3c2c73c commit f658d46
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion app/Models/Contest.php
Original file line number Diff line number Diff line change
Expand Up @@ -302,14 +302,24 @@ public function entriesByType($user = null, array $preloads = [])
// Only return contest entries that a user has actually played
return $entries
->whereIn('entry_url', function ($query) use ($user) {
$options = $this->getExtraOptions()['best_of'];
$ruleset = $options['mode'] ?? 'osu';
$query->select('beatmapset_id')
->from('osu_beatmaps')
->where('osu_beatmaps.playmode', Beatmap::MODES[$this->getExtraOptions()['best_of']['mode'] ?? 'osu'])
->where('osu_beatmaps.playmode', Beatmap::MODES[$ruleset])
->whereIn('beatmap_id', function ($query) use ($user) {
$query->select('beatmap_id')
->from('osu_user_beatmap_playcount')
->where('user_id', '=', $user->user_id);
});

if ($ruleset === 'mania' && isset($options['variant'])) {
$keys = match ($options['variant']) {
'4k' => 4,
'7k' => 7,
};
$query->where('osu_beatmaps.diff_size', $keys);
}
})->get();
}
}
Expand Down

0 comments on commit f658d46

Please sign in to comment.