V10.622 refresh growth cache after offer sync
All checks were successful
CD Pipeline / deploy (push) Successful in 1m3s

This commit is contained in:
OoO
2026-06-16 11:49:06 +08:00
parent 01c73e02a2
commit 3c0e558fbe
8 changed files with 94 additions and 8 deletions

View File

@@ -289,3 +289,10 @@
- 新增 `sync_targeted_momo_candidates_to_external_offers()`,只寫 `ingestion_method='targeted_momo_search'``match_status='verified'``data_quality_status='verified'` 的安全候選;`unit_price` 候選會在 `raw_payload_json.unit_price_comparison` 保留 MOMO / PChome 單位價、容量/數量與價差百分比。
- `build_pchome_growth_opportunities()` 已能讀 `external_offers.raw_payload_json.price_basis='unit_price'`:作戰清單會顯示「資料可用單位價判斷」,並用單位價差距做「檢查售價與活動 / 放大價格優勢」判斷。
- 此路徑只同步外部價格參考與作戰清單,不寫 `competitor_prices`,不自動改價;目標是減少人工補資料,而不是放寬正式價差寫入。
## 25. 2026-06-16 V10.622 外部報價同步後即時刷新作戰清單
- 新增 `services/pchome_growth_cache_state.py`,以 `data/pchome_growth_cache_epoch.txt` 作為跨 Gunicorn worker 的作戰清單快取失效標記。
- `sync_legacy_momo_reference_offers()``sync_targeted_momo_candidates_to_external_offers()` 只要成功寫入 `external_offers`,就呼叫 `mark_pchome_growth_cache_stale()`
- `/api/ai/pchome-growth/opportunities` 的 in-memory cache 會記住建立時的 epoch讀快取前若發現共享 epoch 較新,會直接重建,不再讓使用者看到 120 秒舊清單。
- 這讓「自動找 MOMO 候選 → 同步外部價格參考 → AI 情報頁作戰清單」變成同一條即時資料流,減少使用者手動重新整理或等待快取過期。