Skip to content

Commit

Permalink
Merge pull request #11738 from bdach/filter-by-room-status
Browse files Browse the repository at this point in the history
Add capability to filter by room status
  • Loading branch information
nanaya authored Dec 11, 2024
2 parents 832f2bb + 8d3bdad commit 212a4b1
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions app/Models/Multiplayer/Room.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ class Room extends Model
const PLAYLIST_QUEUE_MODE = 'host_only';
const REALTIME_DEFAULT_QUEUE_MODE = 'host_only';
const REALTIME_QUEUE_MODES = [ 'host_only', 'all_players', 'all_players_round_robin' ];
const REALTIME_STATUSES = ['idle', 'playing'];

public ?array $preloadedRecentParticipants = null;

Expand Down Expand Up @@ -149,6 +150,7 @@ public static function search(array $rawParams, ?int $maxLimit = null)
'mode',
'season_id:int',
'sort',
'status',
'type_group',
'user:any',
], ['null_missing' => true]);
Expand All @@ -157,6 +159,7 @@ public static function search(array $rawParams, ?int $maxLimit = null)
$user = $params['user'];
$seasonId = $params['season_id'];
$sort = $params['sort'];
$status = $params['status'];
$category = $params['category'];
$typeGroup = $params['type_group'];

Expand All @@ -173,6 +176,14 @@ public static function search(array $rawParams, ?int $maxLimit = null)

$query = static::whereIn('type', static::TYPE_GROUPS[$typeGroup]);

if (!in_array($status, static::REALTIME_STATUSES, true)) {
$status = null;
}

if (isset($status)) {
$query->where('status', $status);
}

if (isset($seasonId)) {
$query->whereRelation('seasons', 'seasons.id', $seasonId);
}
Expand Down

0 comments on commit 212a4b1

Please sign in to comment.