Skip already-enriched devices on CARD retry

On retry, only send devices still missing EQUIP_INST_ID to CARD.
Devices that already came back with data on the first pass are
skipped, reducing API calls and wait time when only a subset of
devices timed out.
This commit is contained in:
Jordan Ramos
2026-06-30 14:56:11 -06:00
parent 3d9481d95b
commit 043a20f63d

View File

@@ -258,8 +258,14 @@ export default function LoaderModal({ isOpen, onClose, initialDevices }) {
// --- CARD Enrichment ---
const enrichFromCard = async () => {
const ips = devices.map(d => d.IPV4_ADDRESS).filter(Boolean);
const hostIds = devices.filter(d => !d.IPV4_ADDRESS && d._host_id).map(d => d._host_id);
// Only enrich devices that are still missing EQUIP_INST_ID (skip already-enriched on retry)
const unenriched = devices.filter((d, idx) => {
const rowOverrides = overrides[idx] || {};
return !d.EQUIP_INST_ID && !rowOverrides.EQUIP_INST_ID;
});
const ips = unenriched.map(d => d.IPV4_ADDRESS).filter(Boolean);
const hostIds = unenriched.filter(d => !d.IPV4_ADDRESS && d._host_id).map(d => d._host_id);
if (ips.length === 0 && hostIds.length === 0) return;