|
|
|
@ -1,19 +1,39 @@ |
|
|
|
|
import buildGetRequestHandler from '../buildGetRequestHandler'; |
|
|
|
|
import join from '../../join'; |
|
|
|
|
|
|
|
|
|
export const getServer = buildGetRequestHandler((request) => { |
|
|
|
|
const { anvilsUUID } = request.body; |
|
|
|
|
export const getServer = buildGetRequestHandler( |
|
|
|
|
(request, buildQueryOptions) => { |
|
|
|
|
const { anvilsUUID } = request.body; |
|
|
|
|
|
|
|
|
|
const condAnvilsUUID = join(anvilsUUID, { |
|
|
|
|
beforeReturn: (toReturn) => |
|
|
|
|
toReturn ? `AND server_anvil_uuid IN (${toReturn})` : '', |
|
|
|
|
elementWrapper: "'", |
|
|
|
|
separator: ', ', |
|
|
|
|
}); |
|
|
|
|
const condAnvilsUUID = join(anvilsUUID, { |
|
|
|
|
beforeReturn: (toReturn) => |
|
|
|
|
toReturn ? `AND server_anvil_uuid IN (${toReturn})` : '', |
|
|
|
|
elementWrapper: "'", |
|
|
|
|
separator: ', ', |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
console.log(`condAnvilsUUID=[${condAnvilsUUID}]`); |
|
|
|
|
console.log(`condAnvilsUUID=[${condAnvilsUUID}]`); |
|
|
|
|
|
|
|
|
|
return ` |
|
|
|
|
if (buildQueryOptions) { |
|
|
|
|
buildQueryOptions.afterQueryReturn = (queryStdout) => { |
|
|
|
|
let result = queryStdout; |
|
|
|
|
|
|
|
|
|
if (queryStdout instanceof Array) { |
|
|
|
|
result = queryStdout.map<ServerOverview>( |
|
|
|
|
([serverUUID, serverName, serverState, serverHostUUID]) => ({ |
|
|
|
|
serverHostUUID, |
|
|
|
|
serverName, |
|
|
|
|
serverState, |
|
|
|
|
serverUUID, |
|
|
|
|
}), |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return result; |
|
|
|
|
}; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return ` |
|
|
|
|
SELECT |
|
|
|
|
server_uuid, |
|
|
|
|
server_name, |
|
|
|
@ -22,4 +42,5 @@ export const getServer = buildGetRequestHandler((request) => { |
|
|
|
|
FROM servers |
|
|
|
|
WHERE server_state != 'DELETED' |
|
|
|
|
${condAnvilsUUID};`;
|
|
|
|
|
}); |
|
|
|
|
}, |
|
|
|
|
); |
|
|
|
|