From 775a45f9ebee7ab97cb5a657fb62d10f38284920 Mon Sep 17 00:00:00 2001 From: you Date: Sat, 21 Mar 2026 21:02:12 +0000 Subject: [PATCH] fix: build insert row from packetData instead of DB round-trip packets_v view uses observation IDs, not transmission IDs, so getPacket(transmissionId) returned null. Skip the DB lookup entirely and construct the row directly from the incoming packetData object which already has all needed fields. --- packet-store.js | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/packet-store.js b/packet-store.js index 93f9e9cd..cc080ccc 100644 --- a/packet-store.js +++ b/packet-store.js @@ -308,10 +308,26 @@ class PacketStore { // Also write to normalized tables and get the transmission ID const txResult = this.dbModule.insertTransmission ? this.dbModule.insertTransmission(packetData) : null; const transmissionId = txResult ? txResult.transmissionId : null; - // Use transmissionId to fetch from packets_v (which is based on transmissions+observations) - const lookupId = transmissionId || id; - const row = this.dbModule.getPacket(lookupId); - if (row && !this.sqliteOnly) { + const observationId = txResult ? txResult.observationId : id; + + // Build row directly from packetData — avoids view ID mismatch issues + const row = { + id: observationId, + raw_hex: packetData.raw_hex, + hash: packetData.hash, + timestamp: packetData.timestamp, + route_type: packetData.route_type, + payload_type: packetData.payload_type, + payload_version: packetData.payload_version, + decoded_json: packetData.decoded_json, + observer_id: packetData.observer_id, + observer_name: packetData.observer_name, + snr: packetData.snr, + rssi: packetData.rssi, + path_json: packetData.path_json, + direction: packetData.direction, + }; + if (!this.sqliteOnly) { // Update or create transmission in memory let tx = this.byHash.get(row.hash); if (!tx) {