OoO 0476d3ae4e
All checks were successful
CD Pipeline / deploy (push) Successful in 2m49s
feat(p24): ROI 月報生成器 — 每月 1 日 09:00 推 Telegram
Operation Ollama-First v5.0 / Phase 24 — 戰役 ROI 自動量化

services/roi_report_service.py (200+ 行)
- BASELINE 戰前估算(gemini 50M/$20、nim 5.8M、ollama 30M、total $25/月)
- query_last_month_stats() — SQL 查上月 ai_calls + mcp_calls + rag_query_log
- render_roi_report(stats) — HTML 訊息(含 5 區塊:成本攔截/provider 分布/RAG/MCP+Cache/KPI)
- generate_and_send_roi_report() — 主入口,推 Telegram + 寫 ai_insights 長期記錄
- 達標標記:Gemini -23.5%  / RAG 命中 ≥25% 

Telegram 訊息範例:
  📊 ROI 月報 2026年04月
  💰 成本攔截
    Gemini: 35,000,000 tokens / $14.00
    vs 戰前: 50,000,000 / $20.00
     攔截: 15,000,000 tokens / $6.00 (30.0%)
  🤖 Provider 分布
  🧠 RAG 自主學習(含 saved_call / 反饋分數)
  🔧 MCP + Cache
  📈 戰役 v5.0 KPI  達標

run_scheduler.py — 每日 09:00 跑(內部判斷月初第 1 日才送)
- run_roi_monthly_report_if_new_month task wrapper
- 失敗 swallow log,不影響其他排程

tests/test_roi_report_service.py (7 tests 全綠)
- BASELINE 必要欄位 / 月份範圍計算 (1月→去年12月)
- 達標訊息含  + 攔截數字
- 未達標訊息含 ⚠️
- 空 stats 容錯 / DB fail 回空 dict 不 raise

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-04 11:04:14 +08:00
Description
EwoooC — 商品看板 + 業績報表 + AI KM (Flask + pgvector, Docker Compose on 188)
37 MiB
Languages
PostScript 59.7%
Python 30.9%
HTML 4.2%
CSS 2.1%
JavaScript 1.9%
Other 1.1%