diff --git a/config.py b/config.py index c89107d..d3d8673 100644 --- a/config.py +++ b/config.py @@ -414,7 +414,7 @@ YOUTUBE_API_KEY = os.getenv('YOUTUBE_API_KEY', '') # ========================================== # 系統版本與路徑 # ========================================== -SYSTEM_VERSION = "V10.792" +SYSTEM_VERSION = "V10.793" LOG_FILE_PATH = os.path.join(BASE_DIR, 'logs/system.log') public_url = PUBLIC_URL # 用於模板顯示 diff --git a/routes/dashboard_routes.py b/routes/dashboard_routes.py index 664f597..fbef1d4 100644 --- a/routes/dashboard_routes.py +++ b/routes/dashboard_routes.py @@ -1356,7 +1356,9 @@ def _load_pchome_growth_command_center(session): 'mapping_rate': 0, 'mapping_rate_width': 0, 'comparison_revenue_coverage_rate': 0, + 'comparison_revenue_coverage_width': 0, 'comparison_ready_sales_7d': 0, + 'comparison_total_sales_7d': 0, 'needs_mapping_count': 0, 'mapping_backlog': { 'direct_mapping_count': 0, @@ -1535,6 +1537,11 @@ def _load_pchome_growth_command_center(session): or _to_float(stats.get('comparison_ready_sales_7d')) or 0 ) + comparison_total_sales_7d = ( + _to_float(revenue_coverage.get('denominator')) + or _to_float(stats.get('total_sales_7d')) + or 0 + ) action_code_counts = stats.get('action_code_counts') or {} candidate_count = int(stats.get('candidate_count') or 0) mapped_count = int(stats.get('mapped_count') or 0) @@ -1794,7 +1801,12 @@ def _load_pchome_growth_command_center(session): comparison_revenue_coverage_rate, 1, ), + 'comparison_revenue_coverage_width': round( + max(0, min(100, comparison_revenue_coverage_rate)), + 1, + ), 'comparison_ready_sales_7d': comparison_ready_sales_7d, + 'comparison_total_sales_7d': comparison_total_sales_7d, 'needs_mapping_count': needs_mapping, 'mapping_backlog': mapping_backlog, 'ai_automation_readiness': ai_automation_readiness, diff --git a/templates/dashboard_v2.html b/templates/dashboard_v2.html index 2f2cbc2..285454b 100644 --- a/templates/dashboard_v2.html +++ b/templates/dashboard_v2.html @@ -47,10 +47,10 @@ {{ growth.active_product_count | default(0) | number_format }} 個有銷售商品
- 正式比價覆蓋 - {{ growth.mapping_rate | default(0) }}% -
- {{ growth.mapped_count | default(0) }}/{{ growth.candidate_count | default(0) }} 商品 · 業績涵蓋 {{ growth.comparison_revenue_coverage_rate | default(0) }}% + 業績比價覆蓋 + {{ growth.comparison_revenue_coverage_rate | default(0) }}% +
+ NT$ {{ growth.comparison_ready_sales_7d | default(0) | number_format }} / {{ growth.comparison_total_sales_7d | default(0) | number_format }} · {{ growth.mapped_count | default(0) }}/{{ growth.candidate_count | default(0) }} 商品
最大業績分類 diff --git a/tests/test_pchome_same_item_reconciliation.py b/tests/test_pchome_same_item_reconciliation.py index bedf925..aa0987c 100644 --- a/tests/test_pchome_same_item_reconciliation.py +++ b/tests/test_pchome_same_item_reconciliation.py @@ -318,9 +318,12 @@ def test_dashboard_exposes_count_and_revenue_coverage_without_a_text_wall(): template = Path("templates/dashboard_v2.html").read_text(encoding="utf-8") - assert "正式比價覆蓋" in template - assert "業績涵蓋" in template - assert "growth.comparison_revenue_coverage_rate" in template + assert "業績比價覆蓋" in template + assert "growth.comparison_revenue_coverage_rate | default(0)" in template + assert "growth.comparison_revenue_coverage_width | default(0)" in template + assert "growth.comparison_ready_sales_7d" in template + assert "growth.comparison_total_sales_7d" in template + assert "growth.mapped_count" in template def test_same_item_reconciliation_route_returns_durable_readback(monkeypatch):