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)