Fix issue with missing data

This commit is contained in:
Khalid Adil 2024-09-30 00:20:48 -05:00
parent 21e94fd7ff
commit 101baa58e0

View File

@ -7,14 +7,18 @@ function sortTelemetriesByDate(historicalTelemetriesPool) {
const { identifier } = domainObject; const { identifier } = domainObject;
const telemetryIdentifier = makeKeyString(identifier); const telemetryIdentifier = makeKeyString(identifier);
historicalTelemetry.forEach((historicalTelemetryItem) => { historicalTelemetry.forEach((historicalTelemetryItem) => {
if (!historicalTelemetryDateMap.get(historicalTelemetryItem.utc)) { let telemetryTimestamp = historicalTelemetryItem.utc;
if (historicalTelemetryItem.timestamp) {
telemetryTimestamp = new Date(historicalTelemetryItem.timestamp)?.getTime();
}
if (!historicalTelemetryDateMap.get(telemetryTimestamp)) {
const telemetryMap = new Map(); const telemetryMap = new Map();
telemetryMap.set(telemetryIdentifier, historicalTelemetryItem); telemetryMap.set(telemetryIdentifier, historicalTelemetryItem);
historicalTelemetryDateMap.set(historicalTelemetryItem.utc, telemetryMap); historicalTelemetryDateMap.set(telemetryTimestamp, telemetryMap);
} else { } else {
const telemetryMap = historicalTelemetryDateMap.get(historicalTelemetryItem.utc); const telemetryMap = historicalTelemetryDateMap.get(telemetryTimestamp);
telemetryMap.set(telemetryIdentifier, historicalTelemetryItem); telemetryMap.set(telemetryIdentifier, historicalTelemetryItem);
historicalTelemetryDateMap.set(historicalTelemetryItem.utc, telemetryMap); historicalTelemetryDateMap.set(telemetryTimestamp, telemetryMap);
} }
}); });
}); });