mirror of
https://github.com/LifeArchiveProject/WeChatDataAnalysis.git
synced 2026-02-19 22:30:49 +08:00
feat(wrapped): 新增年度总结接口与卡片 #1(赛博作息表)
- 新增 /api/wrapped/annual(year/account/refresh),统计在 worker thread 中执行 - 实现卡片#1:按 周×小时 聚合消息量,默认过滤 biz_message*.db - 增加 _wrapped/cache JSON 缓存(global_<year>_upto_1.json),refresh 支持强制重算
This commit is contained in:
33
src/wechat_decrypt_tool/wrapped/storage.py
Normal file
33
src/wechat_decrypt_tool/wrapped/storage.py
Normal file
@@ -0,0 +1,33 @@
|
||||
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"
|
||||
Reference in New Issue
Block a user