Adjusted how the in game palyers get counted, now it only counts usern in a created or closed game (not killed anymore)

This commit is contained in:
Vari
2024-08-31 05:06:49 +02:00
parent 6d5698f10e
commit bfdefc7d24

View File

@@ -3,9 +3,11 @@
namespace App\Http\Controllers\Api;
use App\Enums\Game\Matchmaking\MatchmakingSide;
use App\Enums\Game\Matchmaking\MatchStatus;
use App\Http\Controllers\Controller;
use App\Http\Responses\Api\Statistics\OnlinePlayersResponse;
use App\Models\Admin\LauncherMessage;
use App\Models\Game\Matchmaking\Game;
use App\Models\Game\Matchmaking\QueuedPlayer;
use DB;
use Illuminate\Support\Facades\Cache;
@@ -19,7 +21,12 @@ public function getOnlinePlayers() {
return Cache::remember(static::CACHE_KEY, 10, function () {
$queuedHunters = QueuedPlayer::whereSide(MatchmakingSide::Hunter)->count();
$queuedRunners = QueuedPlayer::whereSide(MatchmakingSide::Runner)->count();
$inGamePlayers = DB::table('game_user')->count();
$inGamePlayers = DB::table('game_user')
->join('games', 'game_user.game_id', '=', 'games.id')
->whereIn('games.status', [
MatchStatus::Closed,
MatchStatus::Created,
])->count();
return Response::json(new OnlinePlayersResponse(
$queuedRunners,