Files
ewoooc/routes
OoO 2e124db602
All checks were successful
CD Pipeline / deploy (push) Successful in 2m36s
feat(p47): 6 頁深挖資料庫 — 從 5 表 → 17 表,每頁加 3-5 個 widget
統帥質疑:「6 頁內容太空洞,要更貼近資料庫裡所有數據」
盤點:DB 有 22 表,6 頁原本只用 5 表(22.7% 利用率)。
本 commit 新接 12 張既有但未用的表。

K-1 host_health(接 +5 表 → 8 表)
- 加 incidents 最近 10 筆詳細(task_name/error_type/嚴重度/狀態/重試/錯誤訊息)
- 加 heal_logs 最近 10 筆(action_type/result/耗時/incident 關聯)
- 加 playbooks 庫排行 TOP 12(success_count/fail_count/成功率/啟用狀態)
- 加 backup_log 7 日歷史(type/status/size/duration/error)
- 加 embedding_retry_queue pending/failed 警示

K-2 ai_calls(接 +3 表)
- 加 24h 每小時呼叫趨勢 bucket(含成本+錯誤+流量分布條)
- 加 by model 細分(不只 provider,到 model 版本級別)TOP 15
- 加 agent_context 最近 10 筆(OpenClaw/Hermes 對話 session preview)

K-3 budget(接 +3 表)
- 加當月 Top 5 燒錢呼叫端(caller × cost ranking)
- 加過去 30 日每日成本 by provider 趨勢表
- 加 ai_price_recommendations 7 日統計(strategy 分布 + 平均信心度)

K-4 promotion_review(接 +2 表)
- 加蒸餾池 30 日 status 分布(不只 awaiting,看 8 種完整流動)
- 加 ai_insights 最近 10 筆已晉升內容預覽
- 加 agent_strategy_weights TOP 12(OpenClaw 學習權重 + 成功率)

K-5 quality_trend(接 +3 表)
- 加 RAG 整體 feedback 1-5 分分布(過去 N 日,星等視覺)
- 加 action_plans status 分布(pending/approved/executed/rejected)
- 加 action_outcomes verdict 分布(effective/neutral/backfired
  — ADR-012 閉環學習核心 KPI)

K-6 ppt_audit_history(接 +0 表,但 deeper SQL)
- 加 30 日統計卡(total/passed/failed/error/通過率/總 issue 數/平均信心度)
- 加 Top 10 反覆失敗檔案(30d 失敗次數 + total issues)
- 加 empty state 說明(PPT_VISION_ENABLED=false 時顯示啟用步驟)

DB 利用率對應:
- Phase 38 起點:5 表(22.7%)
- Phase 39-46 累計:12 表(54.5%)
- Phase 47 收官:17 表(77.3%)
  新接:playbooks / backup_log / embedding_retry_queue / agent_context /
        ai_price_recommendations / agent_strategy_weights / action_plans /
        action_outcomes(之前已接:incidents/heal_logs/ai_insights/learning_episodes/
        rag_query_log/mcp_calls/ai_calls/host_health_probes/ppt_audit_results)

每頁 widget 數對應:
- host_health: 5 卡 → 11 卡
- ai_calls: 5 卡 → 8 卡
- budget: 4 卡 → 7 卡
- promotion_review: 2 卡 → 5 卡
- quality_trend: 4 卡 → 7 卡
- ppt_audit: 3 卡 → 6 卡

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-04 19:49:52 +08:00
..

路由模組說明

app.py 直接註冊所有 Flask BlueprintUSE_MODULAR_ROUTESregister_blueprints()MODULAR_ENDPOINTS 與 duplicate cleanup 開關已在 ADR-017 Phase 3f-1 移除。

啟動防線

app.py 會在啟動時檢查 app.url_map,同一組 (URL, HTTP methods) 不允許被兩個 endpoint 重複註冊;若發現衝突會直接 SystemExit

模組清單

模組 說明 主要路由
dashboard_routes.py 商品看板首頁 /
sales_routes.py 業績分析與 ABC 明細 /sales_analysis, /growth_analysis, /abc_analysis/detail, /api/sales_analysis/*
system_public_routes.py 無 prefix 公開系統頁與監控 /health, /metrics, /ai_automation_smoke, /api/ai-automation/smoke*, /settings, /system_settings, /logs, /api/logs, /api/backup
system_routes.py 內部系統維護 API /api/system/*
edm_routes.py EDM 與節慶儀表板 /edm, /festival
monthly_routes.py 月結分析 /monthly_summary_analysis, /api/monthly_summary_data
daily_sales_routes.py 當日業績 /daily_sales, /daily_sales/export*
api_routes.py 通用任務與查詢 API /api/run_task, /api/history/*
export_routes.py 匯出功能 /api/export/*
import_routes.py 匯入功能 /api/import_excel, /api/import/monthly_summary

新增 route 時請優先放入對應 Blueprint並用本機 app.url_map duplicate check 驗證。 若 route 內開始出現大量資料處理、SQL、AI prompt 或外部 API 呼叫,請依 docs/guides/modularization_governance.md 抽到 services/utils/,不要讓 Blueprint 變成新巨檔。