Two things made Opdater show 'Opdatering fejlede': the refresh ran
synchronously (so a slow, rate-limited translate timed out the browser)
and a 429 returned 502. Now:
- /api/offers/refresh starts the work in a background thread and returns
immediately; the button says 'Opdaterer i baggrunden' and reloads a bit
later as batches land. A lock prevents overlapping runs.
- match_offers_ai skips the Claude call when the offer set is unchanged
since the last successful match (hashed), so it runs ~weekly (when the
avis turns over), not every daily refresh — fewer calls, less cost, less
rate pressure.
No signal inside the store made the server-rendered app unusable. Make it
an installable PWA:
- service worker (static/sw.js) caches pages (network-first, cache fallback)
and assets, served from root so scope is /
- offline.js: cittiFetch() queues check-off / price / qty / pick POSTs in
localStorage when offline and replays them in order on reconnect, with an
optimistic response and an Offline/Syncing status badge
- manifest + icon for add-to-home-screen; PWA meta tags on the in-store pages
- in-store mutations (saveToServer, pick/unpick) go through cittiFetch;
archive/refresh/add still need net by design
- Dockerfile copies static/
Open once online first so the SW can cache; then it works offline.
Offers come from the German avis, so add Claude-backed language help,
reusing BlaaAi's ANTHROPIC_API_KEY + Haiku pattern. Both degrade
gracefully: without a key, offers stay German and the token heuristic
still matches.
- Translate offer headings DE→DA in the fetch job, cached per heading
in a translations table (only new headings cost a call). UI shows
Danish primary + German subtitle for in-store navigation.
- AI match the fixed list against offers (offer_matches table): Claude
returns same-product matches, far more precise than the token
heuristic (which false-matched e.g. Nutella jar → advent calendar).
load_deals() prefers AI matches, falls back to the heuristic.
- Haiku 5.5 by default (MATCH_MODEL/TRANSLATE_MODEL env overridable to
Sonnet); no temperature param (Haiku 5.5 rejects non-default).
- requirements: add anthropic
Fetch CITTI Lübeck offers from the Tjek API (German dealer 3czmZx only —
never the Danish Flensburg booklet) and surface them in the app.
- New offers + offer_meta tables; defensive hotspots parser; upsert by
offer id, prune per re-fetched catalog while preserving picked rows
- Daily in-process refresh scheduler (data.db lives on the app's own
Nomad alloc disk, so a separate periodic job can't share it) plus a
manual POST /api/offers/refresh and an "Opdater" button
- /tilbud page: browse all offers by catalog, search, EUR + DKK, and tick
offers onto the shopping list; picks appear in a Lübeck-tilbud section
on the main list and check off as bought via the existing /api/price
- Match the fixed catalog items against current offers and show a
"på tilbud" badge with the matched offer name (conservative word-
boundary token match, >=2 tokens for multi-word names)
- Dockerfile: add ca-certificates for urllib HTTPS to the Tjek API