|
|
|
@ -1,18 +1,22 @@ |
|
|
|
|
import buildGetRequestHandler from '../buildGetRequestHandler'; |
|
|
|
|
import join from '../../join'; |
|
|
|
|
import { sanitizeQS } from '../../sanitizeQS'; |
|
|
|
|
|
|
|
|
|
export const getServer = buildGetRequestHandler( |
|
|
|
|
(request, buildQueryOptions) => { |
|
|
|
|
const { anvilsUUID } = request.body; |
|
|
|
|
const { anvilUUIDs } = request.query; |
|
|
|
|
|
|
|
|
|
const condAnvilsUUID = join(anvilsUUID, { |
|
|
|
|
beforeReturn: (toReturn) => |
|
|
|
|
toReturn ? `AND server_anvil_uuid IN (${toReturn})` : '', |
|
|
|
|
elementWrapper: "'", |
|
|
|
|
separator: ', ', |
|
|
|
|
}); |
|
|
|
|
const condAnvilUUIDs = join( |
|
|
|
|
sanitizeQS(anvilUUIDs, { returnType: 'string[]' }), |
|
|
|
|
{ |
|
|
|
|
beforeReturn: (toReturn) => |
|
|
|
|
toReturn ? `AND server_anvil_uuid IN (${toReturn})` : '', |
|
|
|
|
elementWrapper: "'", |
|
|
|
|
separator: ', ', |
|
|
|
|
}, |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
console.log(`condAnvilsUUID=[${condAnvilsUUID}]`); |
|
|
|
|
console.log(`condAnvilsUUID=[${condAnvilUUIDs}]`); |
|
|
|
|
|
|
|
|
|
if (buildQueryOptions) { |
|
|
|
|
buildQueryOptions.afterQueryReturn = (queryStdout) => { |
|
|
|
@ -34,13 +38,13 @@ export const getServer = buildGetRequestHandler( |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return ` |
|
|
|
|
SELECT |
|
|
|
|
server_uuid, |
|
|
|
|
server_name, |
|
|
|
|
server_state, |
|
|
|
|
server_host_uuid |
|
|
|
|
FROM servers |
|
|
|
|
WHERE server_state != 'DELETED' |
|
|
|
|
${condAnvilsUUID};`;
|
|
|
|
|
SELECT |
|
|
|
|
server_uuid, |
|
|
|
|
server_name, |
|
|
|
|
server_state, |
|
|
|
|
server_host_uuid |
|
|
|
|
FROM servers |
|
|
|
|
WHERE server_state != 'DELETED' |
|
|
|
|
${condAnvilUUIDs};`;
|
|
|
|
|
}, |
|
|
|
|
); |
|
|
|
|