Fix SQl queries being executed unnecessarily when listing servers

This commit is contained in:
Dane Everitt 2018-03-03 18:00:23 -06:00
parent eaf54a8c63
commit a31334c0c5
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53
3 changed files with 4 additions and 3 deletions

View file

@ -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.

View file

@ -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.

View file

@ -51,8 +51,8 @@
<tr class="dynamic-update" data-server="{{ $server->uuidShort }}">
<td @if(! empty($server->description)) rowspan="2" @endif><code>{{ $server->uuidShort }}</code></td>
<td><a href="{{ route('server.index', $server->uuidShort) }}">{{ $server->name }}</a></td>
<td>{{ $server->node->name }}</td>
<td><code>{{ $server->allocation->alias }}:{{ $server->allocation->port }}</code></td>
<td>{{ $server->getRelation('node')->name }}</td>
<td><code>{{ $server->getRelation('allocation')->alias }}:{{ $server->getRelation('allocation')->port }}</code></td>
<td class="text-center hidden-sm hidden-xs"><span data-action="memory">--</span> / {{ $server->memory === 0 ? '&infin;' : $server->memory }} MB</td>
<td class="text-center hidden-sm hidden-xs"><span data-action="cpu" data-cpumax="{{ $server->cpu }}">--</span> %</td>
<td class="text-center">