Include resource total allocations; closes #1518

This commit is contained in:
Dane Everitt 2020-09-17 20:44:24 -07:00
parent f420cd1354
commit c9883b5caf
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53

View file

@ -44,6 +44,13 @@ class NodeTransformer extends BaseTransformer
$response[$node->getUpdatedAtColumn()] = $this->formatTimestamp($node->updated_at); $response[$node->getUpdatedAtColumn()] = $this->formatTimestamp($node->updated_at);
$response[$node->getCreatedAtColumn()] = $this->formatTimestamp($node->created_at); $response[$node->getCreatedAtColumn()] = $this->formatTimestamp($node->created_at);
$resources = $node->servers()->select(['memory', 'disk'])->get();
$response['allocated_resources'] = [
'memory' => $resources->sum('memory'),
'disk' => $resources->sum('disk'),
];
return $response; return $response;
} }