mirror of
https://github.com/LifeArchiveProject/WeChatDataAnalysis.git
synced 2026-02-20 06:40: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:
23
src/wechat_decrypt_tool/routers/wrapped.py
Normal file
23
src/wechat_decrypt_tool/routers/wrapped.py
Normal file
@@ -0,0 +1,23 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import asyncio
|
||||
from typing import Optional
|
||||
|
||||
from fastapi import APIRouter, Query
|
||||
|
||||
from ..path_fix import PathFixRoute
|
||||
from ..wrapped.service import build_wrapped_annual_response
|
||||
|
||||
router = APIRouter(route_class=PathFixRoute)
|
||||
|
||||
|
||||
@router.get("/api/wrapped/annual", summary="微信聊天年度总结(WeChat Wrapped)- 后端数据")
|
||||
async def wrapped_annual(
|
||||
year: Optional[int] = Query(None, description="年份(例如 2026)。默认当前年份。"),
|
||||
account: Optional[str] = Query(None, description="解密后的账号目录名。默认取第一个可用账号。"),
|
||||
refresh: bool = Query(False, description="是否强制重新计算(忽略缓存)。"),
|
||||
):
|
||||
"""返回年度总结数据(目前仅实现第 1 个点子:年度赛博作息表)。"""
|
||||
|
||||
# This endpoint performs blocking sqlite/file IO, so run it in a worker thread.
|
||||
return await asyncio.to_thread(build_wrapped_annual_response, account=account, year=year, refresh=refresh)
|
||||
Reference in New Issue
Block a user