diff --git a/config.py b/config.py index a43057c..3621871 100644 --- a/config.py +++ b/config.py @@ -402,7 +402,7 @@ YOUTUBE_API_KEY = os.getenv('YOUTUBE_API_KEY', '') # ========================================== # 系統版本與路徑 # ========================================== -SYSTEM_VERSION = "V10.694" +SYSTEM_VERSION = "V10.695" 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 6b6839b..810cc57 100644 --- a/docs/AI_INTELLIGENCE_MODULE_SOT.md +++ b/docs/AI_INTELLIGENCE_MODULE_SOT.md @@ -771,3 +771,4 @@ POSTGRES_HOST=momo-db | 2026-06-25 | 候選比較卡與價格語意必須有測試防線 | V10.692 起 `tests/test_pchome_revenue_growth_service.py` 鎖定 `/ai_intelligence` 模板必須提供 PChome/MOMO 雙賣場連結、雙開賣場操作與白話候選理由,且不得再出現 `variant_selection_review`、`focused_exact_identity`、`source_code`、`momo_reference` 或反向價格詞。 | | 2026-06-25 | 成長報表不得把比價內部指標整排丟給使用者 | V10.693 起 `/growth_analysis` 的比價品質區改為「PChome 價格作戰可用度」:只呈現可直接決策、同款覆蓋、價格需刷新、待補/待確認四個訊號,並依資料狀態給下一步建議與今日作戰入口;測試禁止回到「比價資料品質、高信心門檻、未知新鮮度、人工否決」這類工程化列表。 | | 2026-06-25 | 比價頁每筆結果也必須能雙開賣場 | V10.694 起 `/price_comparison` 的結果列在 PChome/MOMO 連結都存在時提供「雙開賣場」操作,Excel 與手動輸入提示改成白話作戰語言,不再顯示「格式說明、欄位、商品名稱,價格」這類工程化提示;`tests/test_frontend_v2_assets.py` 鎖定此行為。 | +| 2026-06-25 | 匯入任務列表只顯示處置提醒 | V10.695 起 `/auto_import` 任務列表不再把 `error_message` 原文當主要欄位顯示,而是由 `buildImportActionHint()` 轉成 Google Drive 授權、當日業績明細檔、重新匯入或通知維護人員等下一步,避免重啟後瀏覽器/授權/同步技術錯誤直接暴露給營運使用者。 | diff --git a/templates/auto_import_index.html b/templates/auto_import_index.html index c807624..d00719a 100644 --- a/templates/auto_import_index.html +++ b/templates/auto_import_index.html @@ -275,7 +275,7 @@ jobs.forEach(job => { const tr = document.createElement('tr'); const fileName = job.drive_file_name || '未記錄檔名'; - const errorMsg = job.display_error_message || job.error_message || '—'; + const actionHint = buildImportActionHint(job); const isRunning = job.status === 'downloading' || job.status === 'importing'; tr.innerHTML = ` @@ -296,7 +296,7 @@ ${formatTime(job.started_at)} ${formatTime(job.completed_at)} - ${escapeHtml(errorMsg)} + ${escapeHtml(actionHint)} ${isRunning ? `` @@ -307,6 +307,31 @@ }); } + function buildImportActionHint(job) { + const status = String(job?.status || ''); + const raw = String(job?.display_error_message || job?.error_message || '').trim(); + const text = raw.toLowerCase(); + if (status === 'completed') { + return '已更新業績資料,可回到今日作戰看建議。'; + } + if (status === 'downloading' || status === 'importing' || status === 'pending') { + return '匯入進行中,完成後會更新日報與今日作戰。'; + } + if (status === 'failed') { + if (text.includes('google drive') || raw.includes('雲端') || raw.includes('授權')) { + return '重新確認 Google Drive 授權,確認後再執行立即匯入。'; + } + if (raw.includes('格式') || raw.includes('日期') || raw.includes('商品') || raw.includes('業績') || text.includes('excel')) { + return '改用當日業績明細檔,確認包含日期、商品與業績金額後重新匯入。'; + } + if (raw.includes('同步') || raw.includes('未完整') || raw.includes('重啟')) { + return '重新匯入最新檔案;若重複失敗,請通知維護人員檢查同步流程。'; + } + return '檢查檔案後重新匯入;若重複失敗,請通知維護人員。'; + } + return raw || '等待系統更新任務狀態。'; + } + // ───── 工具 ───── function escapeHtml(text) { if (!text) return ''; diff --git a/tests/test_pchome_revenue_growth_service.py b/tests/test_pchome_revenue_growth_service.py index 5e1dd77..0df185a 100644 --- a/tests/test_pchome_revenue_growth_service.py +++ b/tests/test_pchome_revenue_growth_service.py @@ -845,7 +845,16 @@ def test_governance_and_low_frequency_pages_avoid_engineering_status_copy(): "templates/components/_legacy_bridge_panel.html": ["頁面狀態", "已整併", "業績流程可用"], "templates/403.html": ["權限守門", "未授權操作影響營運資料", "權限控管"], "templates/maintenance.html": ["服務維護", "確認業績、比價與匯入狀態", "台北時間"], - "templates/auto_import_index.html": ["更新日報、成長分析與今日作戰清單", "去重後寫入業績快照", "作戰清單保持新鮮", "共更新"], + "templates/auto_import_index.html": [ + "更新日報、成長分析與今日作戰清單", + "去重後寫入業績快照", + "作戰清單保持新鮮", + "共更新", + "buildImportActionHint", + "重新確認 Google Drive 授權", + "改用當日業績明細檔", + "重新匯入最新檔案", + ], "templates/settings.html": ["比價來源同步", "補齊 MOMO 參考來源"], "templates/system_settings.html": ["營運資料備份", "可回復的業績與設定狀態"], "templates/ai_recommend.html": ["值得主推、調價或補比價", "回到 PChome 銷售動作"],