fix: set header observer/path to earliest observation on DB load

During _loadNormalized(), observations load in DESC order so the first
observation processed is the LATEST. tx.observer_id was set from this
latest observation. Added post-load pass that finds the earliest
observation by timestamp and sets tx.observer_id/path_json to match.
This commit is contained in:
you
2026-03-21 23:10:10 +00:00
parent 1dc5daab67
commit f1e3a57fcf
+16
View File
@@ -156,6 +156,22 @@ class PacketStore {
}
}
// Post-load: set each transmission's observer/path to the EARLIEST observation
for (const tx of this.packets) {
if (tx.observations.length > 0) {
let earliest = tx.observations[0];
for (let i = 1; i < tx.observations.length; i++) {
if (tx.observations[i].timestamp < earliest.timestamp) earliest = tx.observations[i];
}
tx.observer_id = earliest.observer_id;
tx.observer_name = earliest.observer_name;
tx.snr = earliest.snr;
tx.rssi = earliest.rssi;
tx.path_json = earliest.path_json;
tx.direction = earliest.direction;
}
}
// Post-load: build ADVERT-by-observer index (needs all observations loaded first)
for (const tx of this.packets) {
if (tx.payload_type === 4 && tx.decoded_json) {