A station that last transmitted yesterday evening disappears from its info page while its packets page still lists it #52

Open
opened 2026-11-03 18:52:28 +00:00 by skippy-bot · 0 comments

Problem

Latest-packet lookups cut off at a rolling instant (now minus retention days), but partitions are dropped on a day boundary, so with one day retention the previous day's partition is still present for most of today while every lookup refuses rows older than the cutoff. A station whose last packet was between midnight and the cutoff time yesterday is still listed on /packets/:callsign, its info page renders the not-found empty state, clicking it on the map does not center anything, and the callsign API answers not found.

Evidence

At 2f150f66:

  • lib/aprsme/packets/prepared_queries.ex:26 and :44 bound both latest-packet queries with where: p.received_at >= ^cutoff.
  • lib/aprsme/packets/prepared_queries.ex:70 computes that cutoff as DateTime.shift(DateTime.utc_now(), day: -retention_days), a rolling instant.
  • lib/aprsme/packets/prepared_queries.ex:20 documents the assumption that cleanup already removed those rows, which the partition boundary contradicts.
  • lib/aprsme/partition_manager.ex:90 and :98 drop a partition only once its upper bound passes the same rolling cutoff, so the day's first hours remain readable in the table.
  • lib/aprsme/packets.ex:496 lists a callsign's packets with no received_at bound, which is why the packets page and the info page disagree.
  • lib/aprsme_web/live/info_live/show.ex:246 renders the same empty state for nil as for an unknown callsign.

Expected

The query bound matches what retention actually keeps: if the oldest retained partition starts at day D 00:00, a packet received at D 01:00 is found. Floor the cutoff to the start of the oldest retained day, or align the partition drop to the same instant.

How to verify

Insert a packet at yesterday 01:00 with retention 1, run the partition drop (nothing qualifies), then call Aprsme.Packets.get_latest_packet_for_callsign/1 and get_packets_for_callsign/2: the second returns the row and the first returns nil.

Acceptance criteria

  • A packet inside a partition that still exists is never hidden by a latest-packet lookup.
  • The info page, the map centering path and GET /api/v1/callsign/:callsign agree with /packets/:callsign.
  • A test covers a packet just after midnight on the oldest retained day.

Effort: S
Lens: data

## Problem Latest-packet lookups cut off at a rolling instant (now minus retention days), but partitions are dropped on a day boundary, so with one day retention the previous day's partition is still present for most of today while every lookup refuses rows older than the cutoff. A station whose last packet was between midnight and the cutoff time yesterday is still listed on `/packets/:callsign`, its info page renders the not-found empty state, clicking it on the map does not center anything, and the callsign API answers not found. ## Evidence At `2f150f66`: - `lib/aprsme/packets/prepared_queries.ex:26` and `:44` bound both latest-packet queries with `where: p.received_at >= ^cutoff`. - `lib/aprsme/packets/prepared_queries.ex:70` computes that cutoff as `DateTime.shift(DateTime.utc_now(), day: -retention_days)`, a rolling instant. - `lib/aprsme/packets/prepared_queries.ex:20` documents the assumption that cleanup already removed those rows, which the partition boundary contradicts. - `lib/aprsme/partition_manager.ex:90` and `:98` drop a partition only once its upper bound passes the same rolling cutoff, so the day's first hours remain readable in the table. - `lib/aprsme/packets.ex:496` lists a callsign's packets with no received_at bound, which is why the packets page and the info page disagree. - `lib/aprsme_web/live/info_live/show.ex:246` renders the same empty state for nil as for an unknown callsign. ## Expected The query bound matches what retention actually keeps: if the oldest retained partition starts at day D 00:00, a packet received at D 01:00 is found. Floor the cutoff to the start of the oldest retained day, or align the partition drop to the same instant. ## How to verify Insert a packet at yesterday 01:00 with retention 1, run the partition drop (nothing qualifies), then call `Aprsme.Packets.get_latest_packet_for_callsign/1` and `get_packets_for_callsign/2`: the second returns the row and the first returns nil. ## Acceptance criteria - [ ] A packet inside a partition that still exists is never hidden by a latest-packet lookup. - [ ] The info page, the map centering path and `GET /api/v1/callsign/:callsign` agree with `/packets/:callsign`. - [ ] A test covers a packet just after midnight on the oldest retained day. **Effort:** S **Lens:** data
Sign in to join this conversation.
No description provided.