Skip to content

Commit

Permalink
Merge pull request #11488 from notbakaneko/feature/room-highscore-fil…
Browse files Browse the repository at this point in the history
…ter-restricted

Filter out restricted user from Playlist scores
  • Loading branch information
nanaya authored Sep 13, 2024
2 parents 6f1464b + 8e595db commit c029567
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,10 @@ public function index($roomId, $playlistId)
$limit = clamp(get_int($params['limit'] ?? null) ?? 50, 1, 50);
$cursorHelper = PlaylistItemUserHighScore::makeDbCursorHelper($params['sort'] ?? null);

$highScoresQuery = $playlist->highScores()->whereHas('scoreLink');
$highScoresQuery = $playlist
->highScores()
->whereHas('user', fn ($userQuery) => $userQuery->default())
->whereHas('scoreLink');

[$highScores, $hasMore] = $highScoresQuery
->clone()
Expand Down
6 changes: 6 additions & 0 deletions app/Models/Multiplayer/PlaylistItemUserHighScore.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

use App\Models\Model;
use App\Models\Traits\WithDbCursorHelper;
use App\Models\User;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

Expand Down Expand Up @@ -106,6 +107,11 @@ public function scoreLink()
return $this->belongsTo(ScoreLink::class, 'score_id');
}

public function user(): BelongsTo
{
return $this->belongsTo(User::class, 'user_id');
}

public function scopePassing(Builder $query): Builder
{
return $query->where('total_score', '>', 0);
Expand Down

0 comments on commit c029567

Please sign in to comment.