From 4a268c4b579314bb787138f0d69e68ed11b4b4a4 Mon Sep 17 00:00:00 2001 From: Tsu-ba-me Date: Thu, 23 Jun 2022 16:29:13 -0400 Subject: [PATCH] fix(striker-ui-api): add anvil node pair info to /server --- .../lib/request_handlers/server/getServer.ts | 29 ++++++++++++++----- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/striker-ui-api/src/lib/request_handlers/server/getServer.ts b/striker-ui-api/src/lib/request_handlers/server/getServer.ts index 42732da4..402bbbe7 100644 --- a/striker-ui-api/src/lib/request_handlers/server/getServer.ts +++ b/striker-ui-api/src/lib/request_handlers/server/getServer.ts @@ -10,7 +10,7 @@ export const getServer = buildGetRequestHandler( sanitizeQS(anvilUUIDs, { returnType: 'string[]' }), { beforeReturn: (toReturn) => - toReturn ? `AND server_anvil_uuid IN (${toReturn})` : '', + toReturn ? `AND ser.server_anvil_uuid IN (${toReturn})` : '', elementWrapper: "'", separator: ', ', }, @@ -24,11 +24,20 @@ export const getServer = buildGetRequestHandler( if (queryStdout instanceof Array) { result = queryStdout.map( - ([serverUUID, serverName, serverState, serverHostUUID]) => ({ + ([ + serverUUID, + serverName, + serverState, + serverHostUUID, + anvilUUID, + anvilName, + ]) => ({ serverHostUUID, serverName, serverState, serverUUID, + anvilUUID, + anvilName, }), ); } @@ -39,12 +48,16 @@ export const getServer = buildGetRequestHandler( return ` SELECT - server_uuid, - server_name, - server_state, - server_host_uuid - FROM servers - WHERE server_state != 'DELETED' + ser.server_uuid, + ser.server_name, + ser.server_state, + ser.server_host_uuid, + anv.anvil_uuid, + anv.anvil_name + FROM servers AS ser + JOIN anvils AS anv + ON ser.server_anvil_uuid = anv.anvil_uuid + WHERE ser.server_state != 'DELETED' ${condAnvilUUIDs};`; }, );