From 79a26c77f39ea1d550836dea8cd4cc88925b8f9a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B5=85=E5=BF=B5?= Date: Tue, 15 Sep 2026 13:53:06 +0800 Subject: [PATCH] =?UTF-8?q?docs:=20Task11=20=E5=A2=9E=E5=8A=A0=E5=85=B1?= =?UTF-8?q?=E4=BA=AB=20daily=5Fcounts=20=E5=AE=9E=E7=8E=B0=E7=BA=A6?= =?UTF-8?q?=E6=9D=9F=EF=BC=88Task8=20=E5=AE=A1=E6=9F=A5=E7=BB=93=E8=AE=BA?= =?UTF-8?q?=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Code --- .../plans/2026-09-15-m1-data-collection-foundation.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/superpowers/plans/2026-09-15-m1-data-collection-foundation.md b/docs/superpowers/plans/2026-09-15-m1-data-collection-foundation.md index cb182ca..df600ba 100644 --- a/docs/superpowers/plans/2026-09-15-m1-data-collection-foundation.md +++ b/docs/superpowers/plans/2026-09-15-m1-data-collection-foundation.md @@ -1143,7 +1143,7 @@ def test_overview_shape(db, client, django_user_model): assert r.json()["data"]["sources"][0]["source"] == "google.com" assert r.json()["data"]["top_pages"][0]["path"] == "/pricing" ``` -- [ ] **Step 2: 实现**:`today` 用事件/会话表实时聚合(当天 Asia/Shanghai 边界);`trend` 取 DailyStat 近 30 天(缺日补零;今天用实时值覆盖最后一位);`sources` = 当天 VisitSession group by `referrer_domain`(空→"直接访问")top8;`top_pages` = 当天 page_view group by path top8;`active_now` = `Visitor.last_seen_at > now-5min` 计数(**不要用** `Event.received_at`——无索引会全表扫;last_seen_at 每批刷新且已有索引,语义等价)。认证 + 成员权限。**所有聚合排除 `is_bot=True`(爬虫不进 Dashboard)。** +- [ ] **Step 2: 实现**:`today` 用事件/会话表实时聚合(当天 Asia/Shanghai 边界);`trend` 取 DailyStat 近 30 天(缺日补零;今天用实时值覆盖最后一位);`sources` = 当天 VisitSession group by `referrer_domain`(空→"直接访问")top8;`top_pages` = 当天 page_view group by path top8;`active_now` = `Visitor.last_seen_at > now-5min` 计数(**不要用** `Event.received_at`——无索引会全表扫;last_seen_at 每批刷新且已有索引,语义等价)。认证 + 成员权限。**所有聚合排除 `is_bot=True`(爬虫不进 Dashboard)**。**实现约束(Task 8 审查结论):pv/uv/sessions/new_visitors 提取为 stats.py 共享 `daily_counts(site, date)`,refresh_daily 与 dashboard today 共用,防两处口径漂移(Task 8 的 new_visitors 爬虫口径问题正是反例)。** - [ ] **Step 3: 测试通过,Commit** `feat: 总览聚合接口` ### Task 12: 访客列表/详情/时间线/会话 API