Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions app/Http/Controllers/Ranking/MatchmakingController.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,26 @@ class MatchmakingController extends Controller
'rating' => [['rating', 'DESC'], ['total_points', 'DESC']],
];

public function show(?string $rulesetName = null, ?string $poolId = null)
public function show(?string $poolType = null, ?string $rulesetName = null, ?string $poolId = null)
{
$poolType ??= MatchmakingPool::TYPES[0];

$rulesetName ??= default_mode();
$rulesetId = Beatmap::MODES[$rulesetName] ?? abort(422, 'invalid ruleset parameter');

$poolsQuery = MatchmakingPool::where(['ruleset_id' => $rulesetId])->orderByDesc('active')->orderByDesc('id');
$poolsQuery = MatchmakingPool::where([
'type' => $poolType,
'ruleset_id' => $rulesetId,
])->orderByDesc('active')->orderByDesc('id');

if ($poolId === null) {
$pool = $poolsQuery->firstOrFail();

return ujs_redirect(route('rankings.matchmaking', ['mode' => $rulesetName, 'pool' => $pool->getKey()]));
return ujs_redirect(route('rankings.matchmaking', [
'poolType' => $poolType,
'mode' => $rulesetName,
'pool' => $pool->getKey(),
]));
}

$pools = $poolsQuery->get();
Expand All @@ -37,7 +46,7 @@ public function show(?string $rulesetName = null, ?string $poolId = null)
$query = $pool->allUserStats()->with('user.team')->default();

$sort = get_string(request('sort'));
if (!array_key_exists($sort, static::SORTS)) {
if (!array_key_exists($sort, static::SORTS) || !$pool->hasPoints()) {
$sort = 'rating';
}
foreach (static::SORTS[$sort] as $dbSort) {
Expand Down
6 changes: 5 additions & 1 deletion app/Http/Controllers/RankingController.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use App\Models\Beatmap;
use App\Models\Country;
use App\Models\CountryStatistics;
use App\Models\MatchmakingPool;
use App\Models\Model;
use App\Models\Spotlight;
use App\Models\TeamStatistics;
Expand Down Expand Up @@ -64,7 +65,10 @@ public static function url(
'type' => $params['type'],
]),
'kudosu' => route('rankings.kudosu'),
'matchmaking' => route('rankings.matchmaking', ['mode' => $params['mode'] ?? default_mode()]),
'matchmaking' => route('rankings.matchmaking', [
'poolType' => $params['poolType'] ?? MatchmakingPool::TYPES[0],
'mode' => $params['mode'] ?? default_mode(),
]),
'playlists' => match ($params['list'] ?? 'seasons') {
'charts' => route('rankings', [
'mode' => $params['mode'] ?? default_mode(),
Expand Down
7 changes: 7 additions & 0 deletions app/Models/MatchmakingPool.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
*/
class MatchmakingPool extends Model
{
const array TYPES = ['ranked_play', 'quick_play'];

protected $casts = [
'active' => 'bool',
];
Expand All @@ -44,4 +46,9 @@ public function getDisplayName(): string

return $prefix.$name;
}

public function hasPoints(): bool
{
return $this->type === 'quick_play';
}
}
10 changes: 10 additions & 0 deletions resources/css/bem/ranking-page-grid.less
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,14 @@
--item-padding: 6px 20px;
grid-template-columns: auto 10fr 1fr 1fr 1fr 1fr;
}

&--quick_play {
--item-padding: 6px 20px;
grid-template-columns: auto 10fr 1fr 1fr 1fr 1fr;
}

&--ranked_play {
--item-padding: 6px 20px;
grid-template-columns: auto 10fr 1fr 1fr 1fr;
}
}
3 changes: 2 additions & 1 deletion resources/js/components/basic-select-options.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ interface PropsBase {
type Props = PropsBase & ({
type: 'daily_challenge' | 'download' | 'multiplayer' | 'seasons' | 'spotlight';
} | {
poolType: 'ranked_play' | 'quick_play';
ruleset: Ruleset;
type: 'matchmaking';
});
Expand Down Expand Up @@ -52,7 +53,7 @@ export default class BasicSelectOptions extends React.PureComponent<Props> {
case 'download':
return route('download', { platform: id });
case 'matchmaking':
return route('rankings.matchmaking', { mode: this.props.ruleset, pool: id });
return route('rankings.matchmaking', { mode: this.props.ruleset, pool: id, poolType: this.props.poolType });
case 'multiplayer':
return route('multiplayer.rooms.show', { room: id ?? 'latest' });
case 'seasons':
Expand Down
6 changes: 5 additions & 1 deletion resources/lang/en/rankings.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@
],

'matchmaking' => [
'pool_types' => [
'quick_play' => 'quick play',
'ranked_play' => 'ranked play',
],
'plays' => 'Plays',
'points' => 'Points',
'provisional' => 'Not enough matches played to accurately determine rating',
Expand Down Expand Up @@ -66,7 +70,7 @@
'daily_challenge' => 'daily challenge',
'global' => 'global',
'kudosu' => 'kudosu',
'matchmaking' => 'quick play',
'matchmaking' => 'matchmaking',
'playlists' => 'playlists',
'team' => 'team',
'top_plays' => 'top plays',
Expand Down
20 changes: 20 additions & 0 deletions resources/views/rankings/_pool_type_selector.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{{--
Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the GNU Affero General Public License v3.0.
See the LICENCE file in the repository root for full licence text.
--}}
@php
use App\Models\MatchmakingPool;
@endphp
<div class="page-tabs page-tabs--follows">
@foreach(MatchmakingPool::TYPES as $tab)
<a
class="{{ class_with_modifiers('page-tabs__tab', ['active' => $tab === $params['poolType']]) }}"
href="{{ route('rankings.matchmaking', [
'poolType' => $tab,
'mode' => $params['mode'] ?? default_mode(),
]) }}"
>
{{ osu_trans("rankings.matchmaking.pool_types.{$tab}") }}
</a>
@endforeach
</div>
71 changes: 41 additions & 30 deletions resources/views/rankings/matchmaking.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,50 +5,57 @@
@php
use App\Http\Controllers\Ranking\MatchmakingController;

$params = ['mode' => $rulesetName];
$params = ['poolType' => $pool->type, 'mode' => $rulesetName];
@endphp
@extends('rankings.index', [
'hasPager' => $scores !== null,
'params' => [...$params, 'type' => 'matchmaking'],
'rulesetSelectorUrlFn' => fn (string $r): string => route('rankings.matchmaking', [...$params, 'mode' => $r, 'sort' => $sort]),
'titlePrepend' => osu_trans('rankings.type.matchmaking').': '.$pool->getDisplayName(),
'titlePrepend' => osu_trans("rankings.matchmaking.pool_types.{$pool->type}").': '.$pool->getDisplayName(),
])

@if (count($pools) > 1)
@section('ranking-header')
<div class="osu-page osu-page--ranking-info">
@section('ranking-header')
<div class="osu-page osu-page--ranking-info">
@include('rankings._pool_type_selector', compact('params'))
</div>

@if (count($pools) > 1)
<div class="osu-page osu-page--ranking-info osu-page--ranking-info-extra">
@include('objects._basic_select_options', ['selectOptions' => [
...json_options($pool, $pools, fn ($pool) => [
'id' => $pool->getKey(),
'text' => $pool->getDisplayName(),
]),
'poolType' => $pool->type,
'ruleset' => $rulesetName,
'type' => 'matchmaking',
]])
</div>
@endsection
@endif
@endif
@endsection

@section('scores-header')
<div class="sort">
<div class="sort__items">
<div class="sort__item sort__item--title">
{{ osu_trans('sort._') }}
@if ($pool->hasPoints())
<div class="sort">
<div class="sort__items">
<div class="sort__item sort__item--title">
{{ osu_trans('sort._') }}
</div>
@foreach (MatchmakingController::SORTS as $newSort => $_dbColumns)
<a
class="{{ class_with_modifiers('sort__item', 'button', ['active' => $newSort === $sort]) }}"
href="{{ route('rankings.matchmaking', [...$params, 'pool' => $pool->getKey(), 'sort' => $newSort]) }}"
>
{{ osu_trans("rankings.matchmaking.{$newSort}") }}
</a>
@endforeach
</div>
@foreach (MatchmakingController::SORTS as $newSort => $_dbColumns)
<a
class="{{ class_with_modifiers('sort__item', 'button', ['active' => $newSort === $sort]) }}"
href="{{ route('rankings.matchmaking', [...$params, 'pool' => $pool->getKey(), 'sort' => $newSort]) }}"
>
{{ osu_trans("rankings.matchmaking.{$newSort}") }}
</a>
@endforeach
</div>
</div>
@endif
@endsection

@section('scores')
<div class="ranking-page-grid ranking-page-grid--matchmaking">
<div class="ranking-page-grid ranking-page-grid--{{ $pool->type }}">
<div class="ranking-page-grid-item ranking-page-grid-item--header">
<div class="ranking-page-grid-item__content">
<div class="ranking-page-grid-item__col">
Expand All @@ -61,9 +68,11 @@ class="{{ class_with_modifiers('sort__item', 'button', ['active' => $newSort ===
<div class="ranking-page-grid-item__col">
{{ osu_trans('rankings.matchmaking.plays') }}
</div>
<div class="{{ class_with_modifiers('ranking-page-grid-item__col', ['number-focus' => $sort === 'points']) }}">
{{ osu_trans('rankings.matchmaking.points') }}
</div>
@if ($pool->hasPoints())
<div class="{{ class_with_modifiers('ranking-page-grid-item__col', ['number-focus' => $sort === 'points']) }}">
{{ osu_trans('rankings.matchmaking.points') }}
</div>
@endif
<div class="{{ class_with_modifiers('ranking-page-grid-item__col', ['number-focus' => $sort === 'rating']) }}">
{{ osu_trans('rankings.matchmaking.rating') }}
</div>
Expand All @@ -87,12 +96,14 @@ class="{{ class_with_modifiers('sort__item', 'button', ['active' => $newSort ===
<div class="ranking-page-grid-item__col ranking-page-grid-item__col--number">
{{ i18n_number_format($score->elo_data['contest_count']) }}
</div>
<div class="{{ class_with_modifiers(
'ranking-page-grid-item__col',
$sort === 'points' ? 'number-focus' : 'number',
) }}">
{{ i18n_number_format($score->total_points) }}
</div>
@if ($pool->hasPoints())
<div class="{{ class_with_modifiers(
'ranking-page-grid-item__col',
$sort === 'points' ? 'number-focus' : 'number',
) }}">
{{ i18n_number_format($score->total_points) }}
</div>
@endif
<div class="{{ class_with_modifiers(
'ranking-page-grid-item__col',
$sort === 'rating' ? 'number-focus' : 'number',
Expand Down
2 changes: 1 addition & 1 deletion routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@

Route::get('rankings/kudosu', 'RankingController@kudosu')->name('rankings.kudosu');
Route::resource('rankings/daily-challenge', 'Ranking\DailyChallengeController', ['only' => ['index', 'show']]);
Route::get('rankings/quickplay/{mode?}/{pool?}', 'Ranking\MatchmakingController@show')->name('rankings.matchmaking');
Route::get('rankings/matchmaking/{poolType?}/{mode?}/{pool?}', 'Ranking\MatchmakingController@show')->name('rankings.matchmaking');
Route::get('rankings/top-plays/{mode?}', 'Ranking\TopPlaysController@show')->name('rankings.top-plays');
Route::get('rankings/{mode?}/{type?}/{sort?}', 'RankingController@index')->name('rankings');

Expand Down