navi/backend/services
malice 3c00b69a55
navi-places: place_cache TTL (default 30 days) (#33)
When PR #30 (wikivoyage name-based discovery) landed, every place cached before
the fix kept returning stale (no-wikivoyage) responses until a manual TRUNCATE of
place_cache. A TTL makes enrichment changes propagate automatically.

- place_cache.py: cache_get now treats a hit older than the TTL as a miss, so the
  caller refetches + re-enriches and cache_put overwrites the row (no delete on
  read). TTL is NAVI_PLACE_CACHE_TTL_DAYS (default 30), via _ttl_seconds(). Entries
  with unknown age (cached_at 0/NULL, e.g. legacy rows) are treated as expired.
- No column migration needed: the schema already has cached_at INTEGER NOT NULL and
  cache_put already writes now(). Added an idempotent guard in get_conn anyway
  (PRAGMA table_info check -> ALTER TABLE ADD COLUMN cached_at INTEGER DEFAULT 0)
  so a hypothetical legacy on-disk DB predating the column self-heals; on the live
  DB and fresh DBs it is a no-op since CREATE TABLE already includes cached_at.

Tests (test_place.py): within-TTL hit served from cache (no refetch); past-TTL hit
refetches + refreshes cached_at; NAVI_PLACE_CACHE_TTL_DAYS=1 override expires a
2-day-old entry. Full navi-places suite: 21 passed.

Co-authored-by: Matt <mj@k7zvx.com>
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-26 16:53:25 -06:00
..
navi_admin fix: include navi-offroute (8428) in navi-admin fleet list 2026-05-23 23:17:23 -06:00
navi_config Add navi-admin service (extraction #7) (#7) 2026-05-22 21:21:00 -06:00
navi_contacts Add navi-admin service (extraction #7) (#7) 2026-05-22 21:21:00 -06:00
navi_geo shared: promote dem.py to shared/ (prep for navi-offroute) (#9) 2026-05-22 22:42:47 -06:00
navi_landclass Add navi-admin service (extraction #7) (#7) 2026-05-22 21:21:00 -06:00
navi_offroute navi-offroute: numpy-pack TrailheadIndex (memory opt #2) (#32) 2026-05-26 16:46:22 -06:00
navi_places navi-places: place_cache TTL (default 30 days) (#33) 2026-05-26 16:53:25 -06:00
navi_traffic Add navi-admin service (extraction #7) (#7) 2026-05-22 21:21:00 -06:00