CWG5S4CR45VPX2YMPNTBW3OSWOWWJKGHEGPQFXB3DYWL4MXP424AC const groundZeroTimestamp = new Date(groundZero.fileTimestamp!);
// Ground zero actual call time = file timestamp + selection start timeconst groundZeroFileTimestamp = new Date(groundZero.fileTimestamp!);const groundZeroCallTime = new Date(groundZeroFileTimestamp.getTime() + (parseFloat(groundZero.selectionStartTime!) * 1000));
const timeWindowStart = new Date(groundZeroTimestamp.getTime() - thirtyMinutesMs);const timeWindowEnd = new Date(groundZeroTimestamp.getTime() + thirtyMinutesMs);
const timeWindowStart = new Date(groundZeroCallTime.getTime() - thirtyMinutesMs);const timeWindowEnd = new Date(groundZeroCallTime.getTime() + thirtyMinutesMs);// Expand the file timestamp window to account for selection start times within files// Use a wider window (60 minutes) to ensure we capture all relevant filesconst fileTimeWindowStart = new Date(groundZeroFileTimestamp.getTime() - (60 * 60 * 1000));const fileTimeWindowEnd = new Date(groundZeroFileTimestamp.getTime() + (60 * 60 * 1000));
sqlExpr`${file.timestampLocal} >= ${timeWindowStart.toISOString()}`,sqlExpr`${file.timestampLocal} <= ${timeWindowEnd.toISOString()}`
sqlExpr`${file.timestampLocal} >= ${fileTimeWindowStart.toISOString()}`,sqlExpr`${file.timestampLocal} <= ${fileTimeWindowEnd.toISOString()}`
// Calculate actual call time = file timestamp + selection start timeconst resultFileTimestamp = new Date(result.fileTimestamp!);const resultCallTime = new Date(resultFileTimestamp.getTime() + (parseFloat(result.selectionStartTime!) * 1000));// Only include selections within the 30-minute call time windowif (resultCallTime.getTime() < timeWindowStart.getTime() || resultCallTime.getTime() > timeWindowEnd.getTime()) {return; // Skip this selection}
}// Add filter and species information if availableconst selection = selectionMap.get(selectionId);if (selection && result.filterId && !selection.filters.find((f) => f.id === result.filterId)) {selection.filters.push({id: result.filterId,name: result.filterName || ""});}if (selection && result.speciesId && !selection.species.find((s) => s.id === result.speciesId)) {selection.species.push({id: result.speciesId,name: result.speciesName || ""});
} else {// Selection already exists, just add filter/species if newconst selection = selectionMap.get(selectionId);if (selection && result.filterId && !selection.filters.find((f) => f.id === result.filterId)) {selection.filters.push({id: result.filterId,name: result.filterName || ""});}if (selection && result.speciesId && !selection.species.find((s) => s.id === result.speciesId)) {selection.species.push({id: result.speciesId,name: result.speciesName || ""});}