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:
@@ -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]] # 平局时次序跨请求稳定
|
||||
|
||||
Reference in New Issue
Block a user