Files
ewoooc/services/dashboard_service.py
ogt 4a648ea6bf refactor: fix reverse dependencies — logger_manager→utils, dashboard_service extraction
- Move SystemLogger implementation to utils/logger_manager.py (pure utility, no deps)
- services/logger_manager.py becomes a backward-compat re-export shim
- database/manager.py and database/vendor_manager.py now import from utils layer
- Extract get_dashboard_stats() to services/dashboard_service.py
- services/task_runner.py no longer imports from routes layer
- routes/dashboard_routes.py get_dashboard_stats() delegates to service layer

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-27 21:28:23 +08:00

23 lines
769 B
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
看板統計服務
提供 get_dashboard_stats() 給 task_runner 等 service 層使用,
避免 services 直接 import routes 層(反向依賴)。
"""
def get_dashboard_stats():
"""計算看板統計數據 (供通知使用)"""
# lazy import 避免循環依賴routes 在 Flask app 啟動後才可用
from routes.dashboard_routes import get_full_dashboard_data
data = get_full_dashboard_data()
if data:
return {
'new': data['today_new_products'],
'up': len(data['increase_items_all']),
'down': len(data['decrease_items_all']),
'delisted': data['today_delisted_count']
}
return {'new': 0, 'up': 0, 'down': 0, 'delisted': 0}