10
10
use App \Models \CountryStatistics ;
11
11
use App \Models \Model ;
12
12
use App \Models \Spotlight ;
13
+ use App \Models \TeamStatistics ;
13
14
use App \Models \User ;
14
15
use App \Models \UserStatistics ;
15
16
use App \Transformers \SelectOptionTransformer ;
17
+ use App \Transformers \TeamStatisticsTransformer ;
16
18
use App \Transformers \UserCompactTransformer ;
17
19
use App \Transformers \UserStatisticsTransformer ;
18
20
use DB ;
@@ -31,13 +33,14 @@ class RankingController extends Controller
31
33
32
34
const MAX_RESULTS = 10000 ;
33
35
const PAGE_SIZE = Model::PER_PAGE ;
34
- const RANKING_TYPES = ['performance ' , 'charts ' , 'score ' , 'country ' ];
36
+ const RANKING_TYPES = ['performance ' , 'charts ' , 'score ' , 'country ' , ' team ' ];
35
37
const SPOTLIGHT_TYPES = ['charts ' ];
36
38
// in display order
37
39
const TYPES = [
38
40
'performance ' ,
39
41
'score ' ,
40
42
'country ' ,
43
+ 'team ' ,
41
44
'multiplayer ' ,
42
45
'daily_challenge ' ,
43
46
'seasons ' ,
@@ -170,6 +173,12 @@ public function index($mode, $type)
170
173
->with ('country ' )
171
174
->where ('mode ' , $ modeInt )
172
175
->orderBy ('performance ' , 'desc ' );
176
+ } elseif ($ type === 'team ' ) {
177
+ $ stats = TeamStatistics::where ('ranked_score ' , '> ' , 0 )
178
+ ->where ('ruleset_id ' , $ modeInt )
179
+ ->withCount ('members ' )
180
+ ->with ('team ' )
181
+ ->orderBy ('performance ' , 'desc ' );
173
182
} else {
174
183
$ class = UserStatistics \Model::getClass ($ mode , $ this ->params ['variant ' ]);
175
184
$ table = (new $ class ())->getTable ();
@@ -242,6 +251,10 @@ public function index($mode, $type)
242
251
$ ranking = json_collection ($ stats , 'CountryStatistics ' , ['country ' ]);
243
252
break ;
244
253
254
+ case 'team ' :
255
+ $ ranking = json_collection ($ stats , new TeamStatisticsTransformer (), ['member_count ' , 'team ' ]);
256
+ break ;
257
+
245
258
default :
246
259
$ includes = UserStatisticsTransformer::RANKING_INCLUDES ;
247
260
@@ -399,6 +412,10 @@ private function maxResults($modeInt, $stats)
399
412
->count ();
400
413
}
401
414
415
+ if ($ this ->params ['type ' ] === 'team ' ) {
416
+ return TeamStatistics::where ('ruleset_id ' , $ modeInt )->where ('ranked_score ' , '> ' , 0 )->count ();
417
+ }
418
+
402
419
$ maxResults = static ::MAX_RESULTS ;
403
420
404
421
if ($ this ->params ['variant ' ] !== null ) {
0 commit comments