From a31334c0c50deb96a9aef849749b1d3a6626fdbc Mon Sep 17 00:00:00 2001 From: Dane Everitt Date: Sat, 3 Mar 2018 18:00:23 -0600 Subject: [PATCH] Fix SQl queries being executed unnecessarily when listing servers --- CHANGELOG.md | 1 + app/Repositories/Eloquent/ServerRepository.php | 2 +- resources/themes/pterodactyl/base/index.blade.php | 4 ++-- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a8d3df98e..c5088b525 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ This project follows [Semantic Versioning](http://semver.org) guidelines. ### Fixed * Fixes application API keys being created as a client API key. * Search term is now passed through when using paginated result sets. +* Reduces the number of SQL queries executed when rendering the server listing to increase performance. ### Changed * Databases are now properly paginated when viewing a database host. diff --git a/app/Repositories/Eloquent/ServerRepository.php b/app/Repositories/Eloquent/ServerRepository.php index 5a53d33f0..ec244dd0b 100644 --- a/app/Repositories/Eloquent/ServerRepository.php +++ b/app/Repositories/Eloquent/ServerRepository.php @@ -216,7 +216,7 @@ class ServerRepository extends EloquentRepository implements ServerRepositoryInt */ public function filterUserAccessServers(User $user, int $level, bool $paginate = true) { - $instance = $this->getBuilder()->select($this->getColumns())->with(['user']); + $instance = $this->getBuilder()->select($this->getColumns())->with(['user', 'node', 'allocation']); // If access level is set to owner, only display servers // that the user owns. diff --git a/resources/themes/pterodactyl/base/index.blade.php b/resources/themes/pterodactyl/base/index.blade.php index cb5a9f616..95cce6128 100644 --- a/resources/themes/pterodactyl/base/index.blade.php +++ b/resources/themes/pterodactyl/base/index.blade.php @@ -51,8 +51,8 @@ description)) rowspan="2" @endif>{{ $server->uuidShort }} {{ $server->name }} - {{ $server->node->name }} - {{ $server->allocation->alias }}:{{ $server->allocation->port }} + {{ $server->getRelation('node')->name }} + {{ $server->getRelation('allocation')->alias }}:{{ $server->getRelation('allocation')->port }} -- / {{ $server->memory === 0 ? '∞' : $server->memory }} MB -- %