@@ -307,6 +307,7 @@ public function getAttribute($key)
307307 'baseMaxCombo ' ,
308308 'beatmapDiscussions ' ,
309309 'beatmapOwners ' ,
310+ 'beatmapTags ' ,
310311 'beatmapset ' ,
311312 'difficulty ' ,
312313 'difficultyAttribs ' ,
@@ -392,6 +393,22 @@ public function maxCombo()
392393 return $ maxCombo ?->value;
393394 }
394395
396+ public function slowTopTagIds (): array
397+ {
398+ return $ this ->memoize (__FUNCTION__ , function () {
399+ $ countById = [];
400+ foreach ($ this ->beatmapTags as $ vote ) {
401+ $ countById [$ vote ->tag_id ] ??= ['tag_id ' => $ vote ->tag_id , 'count ' => 0 ];
402+ $ countById [$ vote ->tag_id ]['count ' ]++;
403+ }
404+ usort ($ countById , fn ($ a , $ b ) => $ a ['count ' ] === $ b ['count ' ]
405+ ? $ a ['tag_id ' ] - $ b ['tag_id ' ]
406+ : $ b ['count ' ] - $ a ['count ' ]);
407+
408+ return array_slice ($ countById , 0 , $ GLOBALS ['cfg ' ]['osu ' ]['tags ' ]['top_tag_count ' ]);
409+ });
410+ }
411+
395412 public function status ()
396413 {
397414 return array_search ($ this ->approved , Beatmapset::STATES , true );
@@ -405,7 +422,7 @@ public function topTagIds()
405422 fn () => \Cache::remember (
406423 "beatmap_top_tag_ids: {$ this ->getKey ()}" ,
407424 $ GLOBALS ['cfg ' ]['osu ' ]['tags ' ]['beatmap_tags_cache_duration ' ],
408- fn () => $ this ->beatmapTags ()->topTagIds ()->limit (50 )->get ()->toArray (),
425+ fn () => $ this ->beatmapTags ()->topTagIds ()->limit ($ GLOBALS [ ' cfg ' ][ ' osu ' ][ ' tags ' ][ ' top_tag_count ' ] )->get ()->toArray (),
409426 ),
410427 );
411428 }
0 commit comments