Files
WeChatDataAnalysis/src/wechat_decrypt_tool/wrapped/storage.py
2977094657 519e9e9299 feat(wrapped): 新增年度总结接口与卡片 #1(赛博作息表)
- 新增 /api/wrapped/annual(year/account/refresh),统计在 worker thread 中执行

- 实现卡片#1:按 周×小时 聚合消息量,默认过滤 biz_message*.db

- 增加 _wrapped/cache JSON 缓存(global_<year>_upto_1.json),refresh 支持强制重算
2026-01-30 16:26:04 +08:00

34 lines
986 B
Python

from __future__ import annotations
from pathlib import Path
def wrapped_account_dir(account_dir: Path) -> Path:
"""Return the per-account wrapped working directory.
We keep all wrapped artifacts under `<account>/_wrapped` so they travel
with the decrypted databases and are easy to inspect/backup.
"""
return account_dir / "_wrapped"
def wrapped_cache_dir(account_dir: Path) -> Path:
d = wrapped_account_dir(account_dir) / "cache"
d.mkdir(parents=True, exist_ok=True)
return d
def wrapped_cache_path(
*,
account_dir: Path,
scope: str,
year: int,
implemented_upto: int,
options_tag: str | None = None,
) -> Path:
# NOTE: Keep the filename stable and versioned by "implemented_upto" so when we
# add more cards later we don't accidentally serve a partial cache.
suffix = f"_{options_tag}" if options_tag else ""
return wrapped_cache_dir(account_dir) / f"{scope}_{year}_upto_{implemented_upto}{suffix}.json"