Skip to content

Commit a31334c

Browse files
committed
Fix SQl queries being executed unnecessarily when listing servers
1 parent eaf54a8 commit a31334c

File tree

3 files changed

+4
-3
lines changed

3 files changed

+4
-3
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ This project follows [Semantic Versioning](http://semver.org) guidelines.
77
### Fixed
88
* Fixes application API keys being created as a client API key.
99
* Search term is now passed through when using paginated result sets.
10+
* Reduces the number of SQL queries executed when rendering the server listing to increase performance.
1011

1112
### Changed
1213
* Databases are now properly paginated when viewing a database host.

app/Repositories/Eloquent/ServerRepository.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ public function getDaemonServiceData(Server $server, bool $refresh = false): arr
216216
*/
217217
public function filterUserAccessServers(User $user, int $level, bool $paginate = true)
218218
{
219-
$instance = $this->getBuilder()->select($this->getColumns())->with(['user']);
219+
$instance = $this->getBuilder()->select($this->getColumns())->with(['user', 'node', 'allocation']);
220220

221221
// If access level is set to owner, only display servers
222222
// that the user owns.

resources/themes/pterodactyl/base/index.blade.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@
5151
<tr class="dynamic-update" data-server="{{ $server->uuidShort }}">
5252
<td @if(! empty($server->description)) rowspan="2" @endif><code>{{ $server->uuidShort }}</code></td>
5353
<td><a href="{{ route('server.index', $server->uuidShort) }}">{{ $server->name }}</a></td>
54-
<td>{{ $server->node->name }}</td>
55-
<td><code>{{ $server->allocation->alias }}:{{ $server->allocation->port }}</code></td>
54+
<td>{{ $server->getRelation('node')->name }}</td>
55+
<td><code>{{ $server->getRelation('allocation')->alias }}:{{ $server->getRelation('allocation')->port }}</code></td>
5656
<td class="text-center hidden-sm hidden-xs"><span data-action="memory">--</span> / {{ $server->memory === 0 ? '&infin;' : $server->memory }} MB</td>
5757
<td class="text-center hidden-sm hidden-xs"><span data-action="cpu" data-cpumax="{{ $server->cpu }}">--</span> %</td>
5858
<td class="text-center">

0 commit comments

Comments
 (0)