From ff642207413704e8d31f4f910d70090cf0643928 Mon Sep 17 00:00:00 2001 From: Dane Everitt Date: Sat, 31 Oct 2020 11:28:31 -0700 Subject: [PATCH] Avoid N+1 location query for servers --- .../Controllers/Api/Remote/Servers/ServerDetailsController.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/Api/Remote/Servers/ServerDetailsController.php b/app/Http/Controllers/Api/Remote/Servers/ServerDetailsController.php index 67a30acf2..d18c0921f 100644 --- a/app/Http/Controllers/Api/Remote/Servers/ServerDetailsController.php +++ b/app/Http/Controllers/Api/Remote/Servers/ServerDetailsController.php @@ -5,6 +5,7 @@ namespace Pterodactyl\Http\Controllers\Api\Remote\Servers; use Illuminate\Http\Request; use Pterodactyl\Models\Server; use Illuminate\Http\JsonResponse; +use Illuminate\Support\Facades\DB; use Pterodactyl\Http\Controllers\Controller; use Pterodactyl\Repositories\Eloquent\NodeRepository; use Pterodactyl\Services\Eggs\EggConfigurationService; @@ -81,7 +82,7 @@ class ServerDetailsController extends Controller // Avoid run-away N+1 SQL queries by pre-loading the relationships that are used // within each of the services called below. - $servers = Server::query()->with('allocations', 'egg', 'mounts', 'variables') + $servers = Server::query()->with('allocations', 'egg', 'mounts', 'variables', 'location') ->where('node_id', $node->id) ->paginate($request->input('per_page', 50));