From 0fff09a15c055f87123ae437864db7587fba6116 Mon Sep 17 00:00:00 2001 From: OoO Date: Sun, 24 May 2026 21:03:02 +0800 Subject: [PATCH] Keep exact counts for filtered PChome reviews --- TODO_NEXT_STEPS.txt | 1 + config.py | 2 +- docs/AI_INTELLIGENCE_MODULE_SOT.md | 2 +- docs/memory/history_logs.md | 1 + routes/dashboard_routes.py | 6 +++++- tests/test_frontend_v2_assets.py | 4 +++- 6 files changed, 12 insertions(+), 4 deletions(-) diff --git a/TODO_NEXT_STEPS.txt b/TODO_NEXT_STEPS.txt index d587514..c913c29 100644 --- a/TODO_NEXT_STEPS.txt +++ b/TODO_NEXT_STEPS.txt @@ -4,6 +4,7 @@ ================================================================================ 【已完成】 + - V10.449 修正 PChome 覆核 exact count 條件:只有預設「全部覆核、無搜尋、無分類」頁跳過 exact count;只要有搜尋詞、分類篩選或單一 review status,就保留精準總數,避免分頁資訊失準。 - V10.448 讓 PChome 覆核「全部」頁跳過 exact count:`review_status=all` 使用 shared overview cache 的待處理總數作為分頁總數提示,只查當頁 50 筆;單一狀態分流仍保留 exact count,降低全量覆核頁互動成本。 - V10.447 反轉 PChome 覆核頁查詢方向:review queue page 先從最新 `competitor_match_attempts` 的可覆核狀態縮小候選,再 join ACTIVE 商品與最新價,並用 `NOT EXISTS` 排除已有有效 identity_v2 正式價;避免每次「全部覆核」先掃全站 ACTIVE 商品。 - V10.446 修正 PChome 覆核頁輕量路徑的 overview timeout:覆核頁總覽改讀已存在的 shared dashboard cache / stale cache,沒有快取時只用目前覆核頁資料補足狀態,不再現場跑 `_load_competitor_decision_overview(session)` 的重型後備 SQL。 diff --git a/config.py b/config.py index a3727db..4a6e6e7 100644 --- a/config.py +++ b/config.py @@ -325,7 +325,7 @@ YOUTUBE_API_KEY = os.getenv('YOUTUBE_API_KEY', '') # ========================================== # 系統版本與路徑 # ========================================== -SYSTEM_VERSION = "V10.448" +SYSTEM_VERSION = "V10.449" LOG_FILE_PATH = os.path.join(BASE_DIR, 'logs/system.log') public_url = PUBLIC_URL # 用於模板顯示 diff --git a/docs/AI_INTELLIGENCE_MODULE_SOT.md b/docs/AI_INTELLIGENCE_MODULE_SOT.md index 6329c14..e81090b 100644 --- a/docs/AI_INTELLIGENCE_MODULE_SOT.md +++ b/docs/AI_INTELLIGENCE_MODULE_SOT.md @@ -2,7 +2,7 @@ > **最後更新**: 2026-05-24 (台北時間) > **狀態**: 🟢 四 AI Agent 自動化閉環已落地;LLM 路由紅線升級為 Ollama-first 三主機級聯,Gemini 備援預設關閉 -> **適用版本**: V10.448 +> **適用版本**: V10.449 --- diff --git a/docs/memory/history_logs.md b/docs/memory/history_logs.md index bb6eae0..29e6a60 100644 --- a/docs/memory/history_logs.md +++ b/docs/memory/history_logs.md @@ -13,6 +13,7 @@ ## 📅 詳細更新日誌 (考古存檔) ### 2026-05-24:PChome 近門檻身份回收第二輪 +- **V10.449 PChome 覆核 exact count 條件修正**: 只有預設「全部覆核、無搜尋、無分類」頁跳過 exact count;若使用搜尋詞、分類篩選或單一 review status,仍保留精準總數,避免操作員分頁資訊失準。 - **V10.448 PChome 覆核全量頁跳過 exact count**: `review_status=all` 改用 shared overview cache 的待處理總數作為分頁總數提示,當頁只查 50 筆;單一狀態分流仍保留 exact count,避免每次操作全量覆核頁都為總筆數重掃整個 review queue。 - **V10.447 PChome 覆核頁查詢方向反轉**: review queue page 改由最新 `competitor_match_attempts` 的可覆核狀態先縮小候選,再 join ACTIVE 商品與最新價,並用 `NOT EXISTS` 排除已有有效 `identity_v2` 正式 PChome 價格;避免「全部覆核」每次先掃全站 ACTIVE 商品後才過濾,提高核心比價覆核頁可操作性。 - **V10.446 PChome 覆核頁 overview timeout 修正**: 覆核頁輕量 render path 的總覽改讀既有 shared dashboard cache / stale cache;若快取不存在,只用目前覆核頁資料補足 review count 與狀態分流,不再即時呼叫 `_load_competitor_decision_overview(session)` 的重型 SQL,避免正式資料量下 statement timeout。 diff --git a/routes/dashboard_routes.py b/routes/dashboard_routes.py index 5f06e02..32676a5 100644 --- a/routes/dashboard_routes.py +++ b/routes/dashboard_routes.py @@ -1711,7 +1711,11 @@ def _render_pchome_review_dashboard( 0, review_status, ) - count_total = review_status != 'all' + count_total = ( + review_status != 'all' + or bool(search_query) + or bool(_normalize_dashboard_category_filter(category_filter)) + ) review_page = _load_competitor_review_page( session, page=page, diff --git a/tests/test_frontend_v2_assets.py b/tests/test_frontend_v2_assets.py index 7010e36..6defc16 100644 --- a/tests/test_frontend_v2_assets.py +++ b/tests/test_frontend_v2_assets.py @@ -138,7 +138,9 @@ def test_dashboard_v2_is_production_default_and_uses_real_dashboard_data(): assert "_build_review_dashboard_items(session, review_queue, today_start_db)" in route_source assert "_load_cached_competitor_overview_for_review(" in route_source assert "_load_competitor_decision_overview(session)" not in route_source - assert "count_total = review_status != 'all'" in route_source + assert "review_status != 'all'" in route_source + assert "or bool(search_query)" in route_source + assert "or bool(_normalize_dashboard_category_filter(category_filter))" in route_source assert "count_total=count_total" in route_source assert "只替 PChome 覆核當頁建立商品列" in route_source assert "_load_competitor_decision_overview(session, unique_items)" in route_source