|
|
@ -11,29 +11,36 @@ const getAnvil = buildGetRequestHandler((request, options) => { |
|
|
|
hos.host_uuid |
|
|
|
hos.host_uuid |
|
|
|
FROM anvils AS anv |
|
|
|
FROM anvils AS anv |
|
|
|
JOIN hosts AS hos |
|
|
|
JOIN hosts AS hos |
|
|
|
ON anv.anvil_uuid = hos.host_anvil_uuid;`;
|
|
|
|
ON hos.host_uuid IN ( |
|
|
|
|
|
|
|
anv.anvil_node1_host_uuid, |
|
|
|
|
|
|
|
anv.anvil_node2_host_uuid, |
|
|
|
|
|
|
|
anv.anvil_dr1_host_uuid |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
ORDER BY anv.anvil_uuid;`;
|
|
|
|
|
|
|
|
|
|
|
|
if (options) { |
|
|
|
if (options) { |
|
|
|
options.afterQueryReturn = (queryStdout) => { |
|
|
|
options.afterQueryReturn = (queryStdout) => { |
|
|
|
let results = queryStdout; |
|
|
|
let results = queryStdout; |
|
|
|
|
|
|
|
|
|
|
|
if (queryStdout instanceof Array) { |
|
|
|
if (queryStdout instanceof Array) { |
|
|
|
let rowStage: AnvilOverview; |
|
|
|
let rowStage: AnvilOverview | undefined; |
|
|
|
|
|
|
|
|
|
|
|
results = queryStdout.reduce<AnvilOverview[]>( |
|
|
|
results = queryStdout.reduce<AnvilOverview[]>( |
|
|
|
(reducedRows, [anvilName, anvilUUID, hostName, hostUUID]) => { |
|
|
|
(reducedRows, [anvilName, anvilUUID, hostName, hostUUID]) => { |
|
|
|
if (rowStage && anvilUUID === rowStage.anvilUUID) { |
|
|
|
if (!rowStage || anvilUUID !== rowStage.anvilUUID) { |
|
|
|
rowStage.hosts.push({ hostName, hostUUID }); |
|
|
|
{ |
|
|
|
} else { |
|
|
|
rowStage = { |
|
|
|
rowStage = { |
|
|
|
anvilName, |
|
|
|
anvilName, |
|
|
|
anvilUUID, |
|
|
|
anvilUUID, |
|
|
|
hosts: [], |
|
|
|
hosts: [], |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
reducedRows.push(rowStage); |
|
|
|
reducedRows.push(rowStage); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
rowStage.hosts.push({ hostName, hostUUID }); |
|
|
|
|
|
|
|
|
|
|
|
return reducedRows; |
|
|
|
return reducedRows; |
|
|
|
}, |
|
|
|
}, |
|
|
|
[], |
|
|
|
[], |
|
|
|