diff --git a/app.py b/app.py index a9444f4..2e932b7 100644 --- a/app.py +++ b/app.py @@ -423,9 +423,12 @@ def match_offers_ai(): # Skip the (daily) match call when the offer set hasn't changed since the # last successful match — the avis only turns over weekly, so this avoids a - # pointless Claude call most days. + # pointless Claude call most days. The leading version forces a re-match + # whenever the matching logic/prompt changes (bump it when editing them). + MATCH_VERSION = "v2-standard-not-premium" sig = hashlib.md5( - "\n".join(sorted(o['id'] + '|' + (o.get('heading') or '') for o in offers)) + (MATCH_VERSION + "\n" + "\n".join( + sorted(o['id'] + '|' + (o.get('heading') or '') for o in offers))) .encode('utf-8')).hexdigest() with get_db() as c: if _meta_get(c, 'last_match_sig') == sig and \ @@ -452,7 +455,10 @@ def match_offers_ai(): "findes. Vær striks: match kun når det tydeligt er samme varetype " "(fx entrecôte↔entrecôte-tilbud). Match IKKE blot på mærke eller løst " "beslægtede varer (fx 'Nutella 1kg glas' må IKKE matche 'Nutella " - "julekalender'). Vælg det billigste ved flere ens. Returnér KUN et " + "julekalender'). Når varen er generisk (fx 'Entrecote ½ kg'), vælg den " + "ALMINDELIGE/standard variant til den LAVESTE pris — undgå premium-/" + "luksus-varianter (Wagyu, Dry-Aged, US-Beef, øko-premium) medmindre varen " + "selv nævner det, da de giver et urealistisk højt estimat. Returnér KUN et " 'JSON-array [{"item_key":"...","offer_id":"..."}] med de sikre match, ' "intet andet.") client = anthropic.Anthropic(max_retries=CLAUDE_MAX_RETRIES) diff --git a/templates/index.html b/templates/index.html index 3ed0492..4783ec7 100644 --- a/templates/index.html +++ b/templates/index.html @@ -71,6 +71,7 @@ .item-name { padding: 0.7rem 0.5rem; font-size: 14px; } .item-name .note { font-size: 11px; color: var(--muted); display: block; margin-top: 1px; } .item-name .de { font-size: 10px; color: #b0aba3; display: block; margin-top: 0; font-style: italic; } + .item-name .row-est-m { display: none; font-size: 10px; color: var(--muted); font-family: var(--mono); margin-top: 2px; } .badge { display: inline-block; font-size: 9px; padding: 1px 5px; border-radius: 3px; margin-left: 5px; vertical-align: middle; font-weight: 500; } .badge-card { background: var(--blue-light); color: var(--blue); } .badge-kasse { background: var(--amber-light); color: var(--amber); } @@ -169,6 +170,7 @@ .header-actions { flex-direction: row; align-items: center; } .item-row { grid-template-columns: 28px 1fr 64px 78px; } .item-est { display: none; } + .item-name .row-est-m { display: block; } .col-headers { grid-template-columns: 28px 1fr 64px 78px; } .col-h:nth-child(4) { display: none; } .extra-item-row { grid-template-columns: 28px 1fr auto auto; } @@ -266,6 +268,7 @@ {% if item.get('note') %}{{ item.note }}{% endif %} {% set d = deals.get(item.key) %} {% if d %}🏷 på tilbud: {{ "{:.2f}".format(d.price_eur).replace(".",",") }} € ≈ {{ "{:.0f}".format(d.price_eur * eur_dkk) }} kr. · {{ d.heading_da or d.heading }}{% endif %} +
{ + const qi = r.querySelector('.item-qty input'); const offer = offerLineDkk(r); // real offer price if matched - if (offer != null) { est += offer; return; } - let base = parseFloat(r.dataset.est) || 0; - const qi = r.querySelector('.item-qty input'); // scale estimate with quantity - if (qi) { - const cur = qtyNum(qi.value.trim() || qi.placeholder); - const def = qtyNum(qi.placeholder); - if (cur != null && def != null && def > 0) base = base * (cur / def); + let line; + if (offer != null) { + line = offer; + } else { + line = parseFloat(r.dataset.est) || 0; + if (qi) { // scale estimate with quantity + const cur = qtyNum(qi.value.trim() || qi.placeholder); + const def = qtyNum(qi.placeholder); + if (cur != null && def != null && def > 0) line = line * (cur / def); + } + } + est += line; + + // Per-row display: computed estimate + ½kg price (for weight items). The + // est column is hidden on phones, so also fill the mobile sub-line. + if (qi) { + const col = r.querySelector('.item-est'); + if (col) col.textContent = line > 0 ? Math.round(line).toLocaleString('da-DK') : '—'; + const sub = r.querySelector('.row-est-m'); + if (sub) { + const kg = qtyToKg(qi.value.trim() || qi.placeholder); + const per500 = (kg > 0 && line > 0) ? Math.round(line / kg * 0.5) : null; + sub.textContent = (line > 0 ? 'est ' + Math.round(line).toLocaleString('da-DK') + ' kr' : '') + + (per500 ? ' · ½kg ' + per500 + ' kr' : ''); + } } - est += base; }); document.getElementById('stat-est').textContent = est > 0 ? Math.round(est).toLocaleString('da-DK') : '—';