Skip to content

Commit 00f70c2

Browse files
authored
Merge pull request #12076 from nanaya/ranking-global
Combine performance and score ranking pages (+ cleanup)
2 parents d17f63f + 31fcdcd commit 00f70c2

File tree

19 files changed

+379
-413
lines changed

19 files changed

+379
-413
lines changed

app/Http/Controllers/RankingController.php

Lines changed: 274 additions & 260 deletions
Large diffs are not rendered by default.

app/Models/Score/Best/Model.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -277,8 +277,12 @@ public function scopeFromCountry($query, $countryAcronym)
277277

278278
public function scopeFriendsOf($query, $user)
279279
{
280-
$userIds = $user->friends()->allRelatedIds();
281-
$userIds[] = $user->getKey();
280+
if ($user === null) {
281+
$userIds = [];
282+
} else {
283+
$userIds = $user->friends()->allRelatedIds();
284+
$userIds[] = $user->getKey();
285+
}
282286

283287
return $query->whereIn('user_id', $userIds);
284288
}

app/Models/UserStatistics/Model.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,8 +198,12 @@ public function isRanked()
198198

199199
public function scopeFriendsOf($query, $user)
200200
{
201-
$userIds = $user->friends()->allRelatedIds();
202-
$userIds[] = $user->getKey();
201+
if ($user === null) {
202+
$userIds = [];
203+
} else {
204+
$userIds = $user->friends()->allRelatedIds();
205+
$userIds[] = $user->getKey();
206+
}
203207

204208
return $query->whereIn('user_id', $userIds);
205209
}

app/helpers.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1180,7 +1180,7 @@ function nav_links()
11801180
'page_title.main.beatmap_packs_controller._' => route('packs.index'),
11811181
];
11821182
foreach (RankingController::TYPES as $rankingType) {
1183-
$links['rankings']["rankings.type.{$rankingType}"] = RankingController::url($rankingType, $defaultMode);
1183+
$links['rankings']["rankings.type.{$rankingType}"] = RankingController::url(['type' => $rankingType]);
11841184
}
11851185
$links['community'] = [
11861186
'page_title.forum._' => route('forum.forums.index'),

resources/css/variables.less

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
@nav2-height: 90px;
4545
@nav2-height--pinned: 50px;
4646
@nav2-header-height: 360px;
47-
@nav2-header-image-height: 340px;
47+
@nav2-header-image-height: 310px;
4848

4949
// mobile nav
5050
// TODO: un-bootstrap names

resources/lang/en/rankings.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,9 @@
3737
'charts' => 'spotlights (old)',
3838
'country' => 'country',
3939
'daily_challenge' => 'daily challenge',
40+
'global' => 'global',
4041
'kudosu' => 'kudosu',
4142
'multiplayer' => 'multiplayer',
42-
'performance' => 'performance',
43-
'score' => 'score',
4443
'seasons' => 'seasons',
4544
'team' => 'team',
4645
],

resources/views/multiplayer/rooms/show.blade.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,8 @@
1010
@extends('rankings.index', [
1111
'hasFilter' => false,
1212
'hasMode' => false,
13-
'hasPager' => true,
13+
'params' => ['type' => 'multiplayer'],
1414
'titlePrepend' => osu_trans('rankings.type.multiplayer').': '.$room->name,
15-
'type' => 'multiplayer',
1615
])
1716

1817
@section('ranking-header')

resources/views/rankings/_country_filter.blade.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@
33
See the LICENCE file in the repository root for full licence text.
44
--}}
55
@php
6+
use App\Models\Country;
67
use App\Transformers\SelectOptionTransformer;
8+
9+
$transformer = new SelectOptionTransformer();
10+
$country = $countryStats?->country;
711
@endphp
812

913
<div class="js-react--ranking-country-filter u-contents">
@@ -21,7 +25,10 @@
2125

2226
<script id="json-country-filter" type="application/json">
2327
{!! json_encode([
24-
'current' => $country === null ? null : json_item($country, new SelectOptionTransformer()),
25-
'items' => $countries,
28+
'current' => $country === null ? null : json_item($country, $transformer),
29+
'items' => json_collection(
30+
Country::whereHasRuleset($params['mode'])->get(),
31+
$transformer,
32+
),
2633
]) !!}
2734
</script>

resources/views/rankings/_main_column.blade.php

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,18 @@
33
See the LICENCE file in the repository root for full licence text.
44
--}}
55
@php
6-
$filter ??= null;
7-
$mode ??= default_mode();
8-
$sort ??= null;
9-
$type ??= 'performance';
10-
$variant ??= null;
6+
$params['filter'] ??= null;
7+
$params['mode'] ??= default_mode();
8+
$params['sort'] ??= null;
9+
$params['type'] ??= 'global';
10+
$params['variant'] ??= null;
1111
@endphp
1212
@if ($object instanceof App\Models\Country)
1313
<a
1414
class="ranking-page-table-main"
1515
href="{{ route('rankings', [
16-
'mode' => $mode,
17-
'type' => 'performance',
16+
'mode' => $params['mode'],
17+
'type' => 'global',
1818
'country' => $object->acronym,
1919
]) }}"
2020
>
@@ -31,8 +31,8 @@ class="ranking-page-table-main"
3131
<a
3232
class="ranking-page-table-main"
3333
href="{{ route('teams.leaderboard', [
34-
'ruleset' => $mode,
35-
'sort' => $sort,
34+
'ruleset' => $params['mode'],
35+
'sort' => $params['sort'],
3636
'team' => $object,
3737
]) }}"
3838
>
@@ -49,13 +49,13 @@ class="ranking-page-table-main"
4949
<a
5050
class="u-contents"
5151
href="{{ route('rankings', [
52-
'mode' => $mode,
53-
'sort' => $sort,
54-
'type' => $type,
52+
'mode' => $params['mode'],
53+
'sort' => $params['sort'],
54+
'type' => $params['type'],
5555
5656
'country' => $object->country->acronym,
57-
'filter' => $filter,
58-
'variant' => $variant,
57+
'filter' => $params['filter'],
58+
'variant' => $params['variant'],
5959
]) }}"
6060
>
6161
@include('objects._flag_country', [
@@ -76,7 +76,7 @@ class="u-contents"
7676
class="ranking-page-table-main__link js-usercard"
7777
data-tooltip-position="right center"
7878
data-user-id="{{ $object->getKey() }}"
79-
href="{{ route('users.show', ['user' => $object->getKey(), 'mode' => $mode]) }}"
79+
href="{{ route('users.show', ['user' => $object->getKey(), 'mode' => $params['mode']]) }}"
8080
>
8181
@if ($showAvatar ?? false)
8282
<span class="ranking-page-table-main__flag">

resources/views/rankings/_user_filter.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
<script id="json-user-filter" type="application/json">
2121
{!! json_encode([
22-
'current' => $filter,
22+
'current' => $params['filter'],
2323
]) !!}
2424
</script>
2525
@endif

0 commit comments

Comments
 (0)