Skip to content

Recently generated letters on the tracking page#5

Merged
ak2k merged 1 commit into
mainfrom
feat/recent-tracking
Jun 5, 2026
Merged

Recently generated letters on the tracking page#5
ak2k merged 1 commit into
mainfrom
feat/recent-tracking

Conversation

@ak2k

@ak2k ak2k commented Jun 5, 2026

Copy link
Copy Markdown
Owner

What

The /tracking page previously required typing a serial + ZIP from memory. It now lists the most recently generated letters as clickable references — clicking a row prefills the form and auto-connects the tracking WebSocket.

Each row shows the recipient name (and company), serial, ZIP, when it was generated, and a coarse status pill (Delivered / In transit / Awaiting first scan).

How

  • db.recent_tracked_imbs() — newest-first registry rows, each enriched with a coarse status derived from its latest stored scan (not a live IV-MTR pull). Rows without a recipient_zip are omitted (can't form a usable link).
  • Capture recipient name + company into tracked_imbs (the generate form already collected them). Added via an idempotent additive migration (ALTER TABLE ADD COLUMN guarded by PRAGMA table_info), so existing on-disk DBs pick up the columns without a destructive rebuild. Legacy rows read NULL and render as "Unnamed recipient". The fields are display-only — they play no part in routing or IV-MTR keying.
  • Gated by SHOW_RECENT_TRACKING (default on) + RECENT_TRACKING_LIMIT (default 20). The site has no auth beyond the webhook IP gate, so the flag is a kill switch for deployments where /tracking is broadly reachable — the list exposes recipient ZIPs/serials to any visitor.

Tests / checks

  • Full suite 287 passed — new coverage for ordering, status derivation, the limit, null-zip omission, name/company round-trip, the additive migration (incl. re-run no-op), and the route's flag on/off + rendered name/company.
  • nix build .#checks.<sys>.lint (ruff check + format) and .typecheck (mypy) clean.
  • Refreshed .secrets.baseline to cover existing test-fixture dummies.

The /tracking page previously required typing a serial + ZIP from memory.
It now lists the most recently generated letters as clickable references,
each prefilling the form (and auto-connecting) on click.

- db.recent_tracked_imbs(): newest-first registry rows enriched with a
  coarse status (delivered / in transit / awaiting first scan) from the
  latest stored scan. Rows without a recipient_zip are omitted.
- Capture recipient name + company into tracked_imbs so the list can show
  who each letter is for. Added via an idempotent additive migration
  (ALTER TABLE ADD COLUMN guarded by PRAGMA table_info), so existing
  on-disk DBs pick up the columns without a destructive rebuild; legacy
  rows read NULL and render as "Unnamed recipient". The fields are
  display-only and play no part in routing or IV-MTR keying.
- Gated by SHOW_RECENT_TRACKING (default on) + RECENT_TRACKING_LIMIT.
  The site has no auth beyond the webhook IP gate, so the flag is a kill
  switch for deployments where /tracking is broadly reachable.

Tests cover ordering, status derivation, the limit, null-zip omission,
name/company round-trip, the additive migration (incl. re-run no-op),
and the route's flag on/off + rendered name/company.

Also refresh .secrets.baseline to cover existing test-fixture dummies.
@ak2k ak2k merged commit 0f0bb39 into main Jun 5, 2026
4 checks passed
@ak2k ak2k deleted the feat/recent-tracking branch June 5, 2026 22:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant