From 026d0e7539827e969bcd7226dbdd7401b8311398 Mon Sep 17 00:00:00 2001 From: OoO Date: Fri, 1 May 2026 21:13:18 +0800 Subject: [PATCH] feat(reports): move monthly analysis to v2 shell --- app.py | 4 +- config.py | 2 +- routes/monthly_routes.py | 3 +- templates/monthly_summary_analysis.html | 142 ++++++++++++++++-------- tests/test_frontend_v2_assets.py | 20 ++++ 5 files changed, 121 insertions(+), 50 deletions(-) diff --git a/app.py b/app.py index 0ca690f..94bd0c5 100644 --- a/app.py +++ b/app.py @@ -95,8 +95,8 @@ except Exception as e: sys_log.error(f"無法檢測磁碟空間: {e}") # 🚩 系統版本定義 (備份與顯示用) -# 🚩 2026-05-01 V10.75: Move AI recommendation page onto V2 shell -SYSTEM_VERSION = "V10.75" +# 🚩 2026-05-01 V10.76: Move monthly analysis report onto V2 shell +SYSTEM_VERSION = "V10.76" # ========================================== # 🔒 SQL Injection 防護函數 diff --git a/config.py b/config.py index 4f1c7fc..7e0fb26 100644 --- a/config.py +++ b/config.py @@ -254,7 +254,7 @@ YOUTUBE_API_KEY = os.getenv('YOUTUBE_API_KEY', '') # ========================================== # 系統版本與路徑 # ========================================== -SYSTEM_VERSION = "V10.75" +SYSTEM_VERSION = "V10.76" LOG_FILE_PATH = os.path.join(BASE_DIR, 'logs/system.log') public_url = PUBLIC_URL # 用於模板顯示 diff --git a/routes/monthly_routes.py b/routes/monthly_routes.py index a9d71ed..c9583bd 100644 --- a/routes/monthly_routes.py +++ b/routes/monthly_routes.py @@ -63,7 +63,8 @@ def monthly_summary_analysis_page(): """月份總表數據分析展示頁 (Phase 9)""" return render_template('monthly_summary_analysis.html', datetime_now=datetime.now(TAIPEI_TZ).strftime('%Y-%m-%d %H:%M:%S'), - system_version=SYSTEM_VERSION) + system_version=SYSTEM_VERSION, + active_page='monthly') # ========================================== diff --git a/templates/monthly_summary_analysis.html b/templates/monthly_summary_analysis.html index a1425da..18fa57d 100644 --- a/templates/monthly_summary_analysis.html +++ b/templates/monthly_summary_analysis.html @@ -1,48 +1,85 @@ - - - +{% extends 'ewoooc_base.html' %} +{% block title %}月份總表數據分析 - WOOO TECH{% endblock %} - - - - 月份總表數據分析 - WOOO TECH - - - +{% block extra_css %} - - + .monthly-analysis-page .table thead th, + .monthly-analysis-page .table-light th { + background: rgba(250, 247, 240, 0.96) !important; + color: var(--momo-text-muted); + font-weight: 800; + } + + @media (max-width: 768px) { + .monthly-analysis-hero { + grid-template-columns: 1fr; + } + } + +{% endblock %} + +{% block ewooo_content %}
- {% include 'components/_navbar.html' %} - -
-
-

月份總表數據分析

-
系統版本: {{ system_version }}
-
+
+
+
+

月份總表數據分析

+

以資料庫 `monthly_summary_analysis` 的月結資料,檢視業績、毛利、YoY 與品牌/區域/價格帶結構。

+
+
+ + {{ system_version }} +
+
@@ -516,12 +567,13 @@
+{% endblock %} + +{% block extra_js %} - - - - - \ No newline at end of file +{% endblock %} diff --git a/tests/test_frontend_v2_assets.py b/tests/test_frontend_v2_assets.py index 0030f74..317ec6e 100644 --- a/tests/test_frontend_v2_assets.py +++ b/tests/test_frontend_v2_assets.py @@ -228,6 +228,26 @@ def test_ai_recommend_uses_v2_shell_and_runtime_category_data(): assert "@ai_bp.route('/api/ai/product_insights'" in route_source +def test_monthly_summary_analysis_uses_v2_shell_and_real_monthly_api(): + template = (ROOT / "templates/monthly_summary_analysis.html").read_text(encoding="utf-8") + route_source = (ROOT / "routes/monthly_routes.py").read_text(encoding="utf-8") + + assert "{% extends 'ewoooc_base.html' %}" in template + assert "{% block ewooo_content %}" in template + assert "{% block extra_css %}" in template + assert "{% block extra_js %}" in template + assert "components/_navbar.html" not in template + assert "" not in template + assert "monthly-analysis-hero" in template + assert "monthly-analysis-page" in template + assert "/api/monthly_summary_data" in template + assert "monthly_summary_analysis" in route_source + assert "active_page='monthly'" in route_source + assert "MonthlySummaryAnalysis" in route_source + assert "mock" not in template.lower() + assert "假商品" not in template + + def test_dashboard_v2_restores_real_price_history_chart(): route_source = (ROOT / "routes/api_routes.py").read_text(encoding="utf-8") dashboard = (ROOT / "templates/dashboard_v2.html").read_text(encoding="utf-8")