From dbac8e9d52c1bf5d00757c480426e7ce56330f3f Mon Sep 17 00:00:00 2001 From: Kpa-clawbot <259247574+Kpa-clawbot@users.noreply.github.com> Date: Fri, 27 Mar 2026 07:53:59 -0700 Subject: [PATCH] fix: Go server since/until filter uses observation timestamp, not first_seen The frontend sends ISO timestamps to filter by observation time. Go was filtering by transmission first_seen which missed packets with recent observations but old first_seen. Now converts ISO to unix epoch and queries the observations table directly. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- cmd/server/db.go | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/cmd/server/db.go b/cmd/server/db.go index b366c79d..046c46d3 100644 --- a/cmd/server/db.go +++ b/cmd/server/db.go @@ -459,12 +459,22 @@ func (db *DB) buildTransmissionWhere(q PacketQuery) ([]string, []interface{}) { args = append(args, strings.ToLower(q.Hash)) } if q.Since != "" { - where = append(where, "t.first_seen > ?") - args = append(args, q.Since) + if t, err := time.Parse(time.RFC3339Nano, q.Since); err == nil { + where = append(where, "t.id IN (SELECT DISTINCT transmission_id FROM observations WHERE timestamp >= ?)") + args = append(args, t.Unix()) + } else { + where = append(where, "t.first_seen > ?") + args = append(args, q.Since) + } } if q.Until != "" { - where = append(where, "t.first_seen < ?") - args = append(args, q.Until) + if t, err := time.Parse(time.RFC3339Nano, q.Until); err == nil { + where = append(where, "t.id IN (SELECT DISTINCT transmission_id FROM observations WHERE timestamp <= ?)") + args = append(args, t.Unix()) + } else { + where = append(where, "t.first_seen < ?") + args = append(args, q.Until) + } } if q.Node != "" { pk := db.resolveNodePubkey(q.Node)