fix(striker-ui-api): add anvil node pair info to /server

main
Tsu-ba-me 3 years ago
parent 0d67310242
commit 4a268c4b57
  1. 29
      striker-ui-api/src/lib/request_handlers/server/getServer.ts

@ -10,7 +10,7 @@ export const getServer = buildGetRequestHandler(
sanitizeQS(anvilUUIDs, { returnType: 'string[]' }), sanitizeQS(anvilUUIDs, { returnType: 'string[]' }),
{ {
beforeReturn: (toReturn) => beforeReturn: (toReturn) =>
toReturn ? `AND server_anvil_uuid IN (${toReturn})` : '', toReturn ? `AND ser.server_anvil_uuid IN (${toReturn})` : '',
elementWrapper: "'", elementWrapper: "'",
separator: ', ', separator: ', ',
}, },
@ -24,11 +24,20 @@ export const getServer = buildGetRequestHandler(
if (queryStdout instanceof Array) { if (queryStdout instanceof Array) {
result = queryStdout.map<ServerOverview>( result = queryStdout.map<ServerOverview>(
([serverUUID, serverName, serverState, serverHostUUID]) => ({ ([
serverUUID,
serverName,
serverState,
serverHostUUID,
anvilUUID,
anvilName,
]) => ({
serverHostUUID, serverHostUUID,
serverName, serverName,
serverState, serverState,
serverUUID, serverUUID,
anvilUUID,
anvilName,
}), }),
); );
} }
@ -39,12 +48,16 @@ export const getServer = buildGetRequestHandler(
return ` return `
SELECT SELECT
server_uuid, ser.server_uuid,
server_name, ser.server_name,
server_state, ser.server_state,
server_host_uuid ser.server_host_uuid,
FROM servers anv.anvil_uuid,
WHERE server_state != 'DELETED' 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};`; ${condAnvilUUIDs};`;
}, },
); );

Loading…
Cancel
Save