chore: dashboard 确定性排序与注释修正

- sources/top_pages Top8 加平局次序键(referrer_domain/path),
  平局时跨请求顺序稳定
- test_dashboard 修正过时注释(b 站数据同为 refresh_daily 真实落行)

pytest 79 passed 无回归。

Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
浅念
2026-09-15 15:06:21 +08:00
parent a0f7bdb87e
commit 0b93814261
2 changed files with 5 additions and 3 deletions
+4 -2
View File
@@ -72,7 +72,8 @@ class OverviewView(EnvelopeMixin, APIView):
q = q.filter(site=site)
return [{"source": r["referrer_domain"] or "直接访问", "sessions": r["n"]}
for r in q.values("referrer_domain")
.annotate(n=Count("id")).order_by("-n")[:8]]
.annotate(n=Count("id"))
.order_by("-n", "referrer_domain")[:8]] # 平局时次序跨请求稳定
def _today_pages(self, site, today):
start, end = _day_bounds(today)
@@ -82,4 +83,5 @@ class OverviewView(EnvelopeMixin, APIView):
q = q.filter(site=site)
return [{"path": r["path"], "pv": r["n"]}
for r in q.values("path")
.annotate(n=Count("id")).order_by("-n")[:8]]
.annotate(n=Count("id"))
.order_by("-n", "path")[:8]] # 平局时次序跨请求稳定