From c9883b5caf9399ef52cd7122b66a272851864578 Mon Sep 17 00:00:00 2001 From: Dane Everitt Date: Thu, 17 Sep 2020 20:44:24 -0700 Subject: [PATCH] Include resource total allocations; closes #1518 --- app/Transformers/Api/Application/NodeTransformer.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/app/Transformers/Api/Application/NodeTransformer.php b/app/Transformers/Api/Application/NodeTransformer.php index d9b8b61f3..c26d67cef 100644 --- a/app/Transformers/Api/Application/NodeTransformer.php +++ b/app/Transformers/Api/Application/NodeTransformer.php @@ -44,6 +44,13 @@ class NodeTransformer extends BaseTransformer $response[$node->getUpdatedAtColumn()] = $this->formatTimestamp($node->updated_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; }