feat(dashboard): optimize cache and AI pick confidence
All checks were successful
CD Pipeline / deploy (push) Successful in 2m46s

This commit is contained in:
OoO
2026-05-01 16:01:52 +08:00
parent 0334051aa7
commit 3920701e1a
9 changed files with 198 additions and 27 deletions

View File

@@ -7,7 +7,9 @@ ADR-017 Phase 3f-2: 將 sales/import/export/daily 會共同碰到的
module-level cache 收斂到這裡,避免各 route 各自持有一份 dict。
"""
import os
import time
from pathlib import Path
class FingerprintCache:
@@ -59,6 +61,8 @@ _DASHBOARD_DATA_CACHE = {
'full_timestamp': None,
}
_DASHBOARD_CACHE_TTL = 1800
_BASE_DIR = Path(__file__).resolve().parents[1]
_DASHBOARD_SHARED_CACHE_FILE = _BASE_DIR / "data" / "dashboard_full_cache.pkl"
def cleanup_sales_cache():
@@ -123,3 +127,9 @@ def clear_dashboard_cache():
'full_data': None,
'full_timestamp': None,
})
try:
os.remove(_DASHBOARD_SHARED_CACHE_FILE)
except FileNotFoundError:
pass
except OSError:
pass