mirror of
https://github.com/LifeArchiveProject/WeChatDataAnalysis.git
synced 2026-02-19 14:20:51 +08:00
- 新增 /api/wrapped/annual(year/account/refresh),统计在 worker thread 中执行 - 实现卡片#1:按 周×小时 聚合消息量,默认过滤 biz_message*.db - 增加 _wrapped/cache JSON 缓存(global_<year>_upto_1.json),refresh 支持强制重算
34 lines
986 B
Python
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"
|