@@ -94,7 +94,7 @@ public function __construct()
94
94
abort (404 );
95
95
}
96
96
97
- if (isset ($ this ->params ['country ' ]) && $ type === ' performance ' ) {
97
+ if (isset ($ this ->params ['country ' ]) && static :: hasCountryFilter ( $ type) ) {
98
98
$ this ->countryStats = CountryStatistics::where ('display ' , 1 )
99
99
->where ('country_code ' , $ this ->params ['country ' ])
100
100
->where ('mode ' , Beatmap::modeInt ($ mode ))
@@ -108,7 +108,7 @@ public function __construct()
108
108
}
109
109
110
110
$ this ->defaultViewVars ['country ' ] = $ this ->country ;
111
- if ($ type === ' performance ' ) {
111
+ if (static :: hasCountryFilter ( $ type) ) {
112
112
$ this ->defaultViewVars ['countries ' ] = json_collection (
113
113
Country::whereHasRuleset ($ mode )->get (),
114
114
new SelectOptionTransformer (),
@@ -133,7 +133,7 @@ public static function url(
133
133
'multiplayer ' => route ('multiplayer.rooms.show ' , ['room ' => 'latest ' ]),
134
134
'seasons ' => route ('seasons.show ' , ['season ' => 'latest ' ]),
135
135
default => route ('rankings ' , [
136
- 'country ' => $ country !== null && $ type === ' performance ' ? $ country ->getKey () : null ,
136
+ 'country ' => $ country !== null && static :: hasCountryFilter ( $ type) ? $ country ->getKey () : null ,
137
137
'mode ' => $ rulesetName ,
138
138
'sort ' => $ sort ,
139
139
'spotlight ' => $ spotlight !== null && $ type === 'charts ' ? $ spotlight ->getKey () : null ,
@@ -142,6 +142,11 @@ public static function url(
142
142
};
143
143
}
144
144
145
+ private static function hasCountryFilter (string $ type ): bool
146
+ {
147
+ return $ type === 'performance ' || $ type === 'score ' ;
148
+ }
149
+
145
150
/**
146
151
* Get Ranking
147
152
*
@@ -207,9 +212,17 @@ public function index($mode, $type, ?string $sort = null)
207
212
208
213
$ stats ->orderBy ('rank_score ' , 'desc ' );
209
214
} else { // 'score'
215
+ if ($ this ->country !== null ) {
216
+ $ stats ->where ('country_acronym ' , $ this ->country ['acronym ' ]);
217
+ // preferrable to ranked_score when filtering by country.
218
+ // On a few countries the default index is slightly better but much worse on the rest.
219
+ $ forceIndex = 'country_ranked_score ' ;
220
+ } else {
221
+ // force to order by ranked_score instead of sucking down entire users table first.
222
+ $ forceIndex = 'ranked_score ' ;
223
+ }
224
+
210
225
$ stats ->orderBy ('ranked_score ' , 'desc ' );
211
- // force to order by ranked_score instead of sucking down entire users table first.
212
- $ forceIndex = 'ranked_score ' ;
213
226
}
214
227
215
228
if ($ this ->friendsOnly ) {
0 commit comments