Change avg ring depth to avg ring consumed percentage
This commit is contained in:
parent
fb04cf0159
commit
6c71af4017
2 changed files with 5 additions and 4 deletions
|
|
@ -29,8 +29,8 @@
|
|||
<span class="analytics-overview-label">Avg Session</span>
|
||||
</div>
|
||||
<div class="analytics-overview-item">
|
||||
<span class="analytics-overview-value">{{ overview.avg_ring_depth }}</span>
|
||||
<span class="analytics-overview-label">Avg Ring Depth</span>
|
||||
<span class="analytics-overview-value">{{ overview.avg_ring_consumed }}</span>
|
||||
<span class="analytics-overview-label">Avg Ring Consumed</span>
|
||||
</div>
|
||||
<div class="analytics-overview-item">
|
||||
<span class="analytics-overview-value">{{ overview.top_source }}</span>
|
||||
|
|
|
|||
|
|
@ -96,7 +96,8 @@ def shop_analytics(request):
|
|||
func.avg(PageSession.wall_clock_ms).label("avg_session_ms"),
|
||||
).filter(_view_filter(cutoff_7d)).one()
|
||||
|
||||
avg_ring_depth = db.query(func.avg(PageSession.ring_position)).filter(
|
||||
ring_size = len(shop.discovery_ring) or 1
|
||||
avg_ring_pct = db.query(func.avg(PageSession.ring_position)).filter(
|
||||
PageSession.shop_id == shop.id,
|
||||
PageSession.ring_position.isnot(None),
|
||||
PageSession.created_timestamp > cutoff_7d,
|
||||
|
|
@ -123,7 +124,7 @@ def shop_analytics(request):
|
|||
"total_views": ov.total_views or 0,
|
||||
"unique_products": ov.unique_products or 0,
|
||||
"avg_session": _fmt_ms(ov.avg_session_ms),
|
||||
"avg_ring_depth": f"{avg_ring_depth:.1f}" if avg_ring_depth else "\u2014",
|
||||
"avg_ring_consumed": _fmt_pct(avg_ring_pct / ring_size) if avg_ring_pct else "\u2014",
|
||||
"top_source": REFERRER_LABELS.get(top_src[0], "\u2014") if top_src else "\u2014",
|
||||
"device_split": dev_split_str,
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue