From 3f9548f33e458ea5b114eaee235b43244034ea15 Mon Sep 17 00:00:00 2001 From: Tsu-ba-me Date: Thu, 10 Aug 2023 16:10:40 -0400 Subject: [PATCH] fix(striker-ui-api): use hosts as core of host detail select query to avoid empty return --- .../host/buildQueryHostDetail.ts | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/striker-ui-api/src/lib/request_handlers/host/buildQueryHostDetail.ts b/striker-ui-api/src/lib/request_handlers/host/buildQueryHostDetail.ts index 488a0bb4..b3456e24 100644 --- a/striker-ui-api/src/lib/request_handlers/host/buildQueryHostDetail.ts +++ b/striker-ui-api/src/lib/request_handlers/host/buildQueryHostDetail.ts @@ -42,41 +42,41 @@ const setCvar = ( export const buildQueryHostDetail: BuildQueryDetailFunction = ({ keys: hostUUIDs = '*', } = {}) => { - const condHostUUIDs = buildKnownIDCondition(hostUUIDs, 'AND b.host_uuid'); + const condHostUUIDs = buildKnownIDCondition(hostUUIDs, 'AND a.host_uuid'); stdout(`condHostUUIDs=[${condHostUUIDs}]`); const query = ` SELECT - b.host_name, - b.host_type, - b.host_uuid, - a.variable_name, - a.variable_value, + a.host_name, + a.host_type, + a.host_uuid, + b.variable_name, + b.variable_value, SUBSTRING( - a.variable_name, '${CVAR_PREFIX_PATTERN}([^:]+)' + b.variable_name, '${CVAR_PREFIX_PATTERN}([^:]+)' ) as cvar_name, SUBSTRING( - a.variable_name, '${CVAR_PREFIX_PATTERN}([a-z]{2,3})\\d+' + b.variable_name, '${CVAR_PREFIX_PATTERN}([a-z]{2,3})\\d+' ) AS network_type, SUBSTRING( - a.variable_name, '${CVAR_PREFIX_PATTERN}[a-z]{2,3}\\d+_(link\\d+)' + b.variable_name, '${CVAR_PREFIX_PATTERN}[a-z]{2,3}\\d+_(link\\d+)' ) AS network_link, c.network_interface_uuid - FROM variables AS a - JOIN hosts AS b - ON a.variable_source_uuid = b.host_uuid + FROM hosts AS a + LEFT JOIN variables AS b + ON b.variable_source_uuid = a.host_uuid LEFT JOIN network_interfaces AS c - ON a.variable_name LIKE '%link%_mac%' - AND a.variable_value = c.network_interface_mac_address - AND b.host_uuid = c.network_interface_host_uuid + ON b.variable_name LIKE '%link%_mac%' + AND b.variable_value = c.network_interface_mac_address + AND a.host_uuid = c.network_interface_host_uuid WHERE ( variable_name LIKE '${CVAR_PREFIX}%' OR variable_name = 'install-target::enabled' ) ${condHostUUIDs} ORDER BY cvar_name ASC, - a.variable_name ASC;`; + b.variable_name ASC;`; const afterQueryReturn: QueryResultModifierFunction = buildQueryResultModifier((output) => {