Skip to content

Commit ff64220

Browse files
committed
Avoid N+1 location query for servers
1 parent c00e5b3 commit ff64220

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

app/Http/Controllers/Api/Remote/Servers/ServerDetailsController.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use Illuminate\Http\Request;
66
use Pterodactyl\Models\Server;
77
use Illuminate\Http\JsonResponse;
8+
use Illuminate\Support\Facades\DB;
89
use Pterodactyl\Http\Controllers\Controller;
910
use Pterodactyl\Repositories\Eloquent\NodeRepository;
1011
use Pterodactyl\Services\Eggs\EggConfigurationService;
@@ -81,7 +82,7 @@ public function list(Request $request)
8182

8283
// Avoid run-away N+1 SQL queries by pre-loading the relationships that are used
8384
// within each of the services called below.
84-
$servers = Server::query()->with('allocations', 'egg', 'mounts', 'variables')
85+
$servers = Server::query()->with('allocations', 'egg', 'mounts', 'variables', 'location')
8586
->where('node_id', $node->id)
8687
->paginate($request->input('per_page', 50));
8788

0 commit comments

Comments
 (0)