e1bd0e3ef7
改了什么:新增新版大盘日期窗口聚合、广告收益拆分、比价耗时字段、美团 CPS 拉单入库与大盘展示,并同步反馈审核和邀请奖励下线口径。 验证:python -m pytest tests/test_admin_read.py tests/test_admin_write.py tests/test_compare_record.py tests/test_invite.py tests/test_feedback.py -q。
28 lines
900 B
Python
28 lines
900 B
Python
"""admin 数据大盘(只读聚合)。"""
|
|
from __future__ import annotations
|
|
|
|
from datetime import date
|
|
|
|
from fastapi import APIRouter, Depends, Query
|
|
|
|
from app.admin.deps import AdminDb, get_current_admin
|
|
from app.admin.repositories import stats
|
|
from app.admin.schemas.dashboard import DashboardOverview
|
|
|
|
router = APIRouter(
|
|
prefix="/admin/api/stats",
|
|
tags=["admin-stats"],
|
|
dependencies=[Depends(get_current_admin)],
|
|
)
|
|
|
|
|
|
@router.get("/overview", response_model=DashboardOverview, summary="大盘核心指标")
|
|
def overview(
|
|
db: AdminDb,
|
|
date_from: date | None = Query(None, description="北京时间自然日起始日 YYYY-MM-DD"),
|
|
date_to: date | None = Query(None, description="北京时间自然日结束日 YYYY-MM-DD"),
|
|
) -> DashboardOverview:
|
|
return DashboardOverview.model_validate(
|
|
stats.dashboard_overview(db, date_from=date_from, date_to=date_to)
|
|
)
|