#!/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}