@@ -56,30 +56,23 @@ public function votes()
56
56
57
57
public function scopeForBestOf (Builder $ query , User $ user , string $ ruleset , ?string $ variant = null ): Builder
58
58
{
59
- $ query ->whereIn ('entry_url ' , function (QueryBuilder $ beatmapsetQuery ) use ($ ruleset , $ user , $ variant ) {
60
- $ beatmapsetQuery ->select ('beatmapset_id ' )
61
- ->from ('osu_beatmaps ' )
62
- ->where ('osu_beatmaps.playmode ' , Beatmap::MODES [$ ruleset ])
63
- ->whereIn ('beatmap_id ' , function (QueryBuilder $ beatmapQuery ) use ($ user ) {
64
- $ beatmapQuery ->select ('beatmap_id ' )
65
- ->from ('osu_user_beatmap_playcount ' )
66
- ->where ('user_id ' , $ user ->getKey ());
67
- });
68
-
69
- if ($ ruleset === 'mania ' && $ variant !== null ) {
70
- if ($ variant === 'nk ' ) {
71
- $ beatmapsetQuery ->whereNotIn ('osu_beatmaps.diff_size ' , [4 , 7 ]);
72
- } else {
73
- $ keys = match ($ variant ) {
74
- '4k ' => 4 ,
75
- '7k ' => 7 ,
76
- };
77
- $ beatmapsetQuery ->where ('osu_beatmaps.diff_size ' , $ keys );
78
- }
59
+ $ beatmapsetIdsQuery = Beatmap::select ('beatmapset_id ' )
60
+ ->where ('playmode ' , Beatmap::MODES [$ ruleset ])
61
+ ->whereIn ('beatmap_id ' , $ user ->beatmapPlaycounts ()->select ('beatmap_id ' ));
62
+
63
+ if ($ ruleset === 'mania ' && $ variant !== null ) {
64
+ if ($ variant === 'nk ' ) {
65
+ $ beatmapsetIdsQuery ->whereNotIn ('osu_beatmaps.diff_size ' , [4 , 7 ]);
66
+ } else {
67
+ $ keys = match ($ variant ) {
68
+ '4k ' => 4 ,
69
+ '7k ' => 7 ,
70
+ };
71
+ $ beatmapsetIdsQuery ->where ('osu_beatmaps.diff_size ' , $ keys );
79
72
}
80
- });
73
+ }
81
74
82
- return $ query ;
75
+ return $ query-> whereIn ( ' entry_url ' , $ beatmapsetIdsQuery ) ;
83
76
}
84
77
85
78
public function scopeWithScore (Builder $ query , array $ options ): Builder
0 commit comments