快取當日業績頁面 context
Some checks failed
CD Pipeline / deploy (push) Has been cancelled

This commit is contained in:
OoO
2026-05-13 12:19:11 +08:00
parent d384c35e51
commit d8c7f6f19c
3 changed files with 84 additions and 2 deletions

View File

@@ -70,6 +70,7 @@ _BASE_DIR = Path(__file__).resolve().parents[1]
_DASHBOARD_SHARED_CACHE_FILE = _BASE_DIR / "data" / "dashboard_full_cache.pkl"
_DASHBOARD_STALE_CACHE_FILE = _BASE_DIR / "data" / "dashboard_full_cache_stale.pkl"
_SALES_ANALYSIS_PAGE_CACHE_DIR = _BASE_DIR / "data" / "sales_analysis_page_cache"
_DAILY_SALES_VIEW_CACHE_DIR = _BASE_DIR / "data" / "daily_sales_view_cache"
def cleanup_sales_cache():
@@ -131,6 +132,15 @@ def clear_sales_cache():
def clear_daily_sales_cache():
"""清除當日業績 cache。"""
_DAILY_SALES_PROCESSED_CACHE.clear()
try:
if _DAILY_SALES_VIEW_CACHE_DIR.exists():
for cache_file in _DAILY_SALES_VIEW_CACHE_DIR.glob("*.pkl"):
try:
cache_file.unlink()
except OSError:
logger.debug("daily sales view cache file cleanup failed: %s", cache_file, exc_info=True)
except OSError:
logger.debug("daily sales view cache cleanup failed", exc_info=True)
def clear_dashboard_cache():