fix(striker-ui-api): simply query table alias in GET host connection

main^2
Tsu-ba-me 7 months ago
parent 850a55151f
commit aaa0a9cfea
  1. 36
      striker-ui-api/src/lib/request_handlers/host/getHostConnection.ts

@ -55,7 +55,7 @@ export const getHostConnection = buildGetRequestHandler(
let rawDatabaseData: AnvilDataDatabaseHash;
const hostUUIDField = 'ip_add.ip_address_host_uuid';
const hostUUIDField = 'a.ip_address_host_uuid';
const localHostUUID: string = getLocalHostUUID();
const { after: condHostUUIDs, before: beforeBuildIDCond } =
buildUnknownIDCondition(rawHostUUIDs, hostUUIDField, {
@ -117,29 +117,29 @@ export const getHostConnection = buildGetRequestHandler(
}
return `SELECT
ip_add.ip_address_uuid,
ip_add.ip_address_host_uuid,
ip_add.ip_address_address,
a.ip_address_uuid,
a.ip_address_host_uuid,
a.ip_address_address,
CASE
WHEN ip_add.ip_address_on_type = 'interface'
WHEN a.ip_address_on_type = 'interface'
THEN (
CASE
WHEN net_int.network_interface_name ~* '.*n\\d+_link\\d+'
THEN net_int.network_interface_name
ELSE net_int.network_interface_device
WHEN b.network_interface_name ~* '.*n\\d+_link\\d+'
THEN b.network_interface_name
ELSE b.network_interface_device
END
)
ELSE bon.bond_active_interface
ELSE d.bond_active_interface
END AS network_name
FROM ip_addresses AS ip_add
LEFT JOIN network_interfaces AS net_int
ON ip_add.ip_address_on_uuid = net_int.network_interface_uuid
LEFT JOIN bridges AS bri
ON ip_add.ip_address_on_uuid = bri.bridge_uuid
LEFT JOIN bonds AS bon
ON bri.bridge_uuid = bon.bond_bridge_uuid
OR ip_add.ip_address_on_uuid = bon.bond_uuid
FROM ip_addresses AS a
LEFT JOIN network_interfaces AS b
ON a.ip_address_on_uuid = b.network_interface_uuid
LEFT JOIN bridges AS c
ON a.ip_address_on_uuid = c.bridge_uuid
LEFT JOIN bonds AS d
ON c.bridge_uuid = d.bond_bridge_uuid
OR a.ip_address_on_uuid = d.bond_uuid
WHERE ${condHostUUIDs}
AND ip_add.ip_address_note != 'DELETED';`;
AND a.ip_address_note != 'DELETED';`;
},
);

Loading…
Cancel
Save