Fix ring consumed to count unique products viewed, not average position index
This commit is contained in:
parent
6c71af4017
commit
f2e88989a2
1 changed files with 5 additions and 3 deletions
|
|
@ -97,11 +97,13 @@ def shop_analytics(request):
|
|||
).filter(_view_filter(cutoff_7d)).one()
|
||||
|
||||
ring_size = len(shop.discovery_ring) or 1
|
||||
avg_ring_pct = db.query(func.avg(PageSession.ring_position)).filter(
|
||||
ring_products_seen = db.query(
|
||||
func.count(func.distinct(PageSession.product_id)),
|
||||
).filter(
|
||||
PageSession.shop_id == shop.id,
|
||||
PageSession.ring_position.isnot(None),
|
||||
PageSession.created_timestamp > cutoff_7d,
|
||||
).scalar()
|
||||
).scalar() or 0
|
||||
|
||||
top_src = db.query(
|
||||
PageSession.referrer_class, func.count().label("cnt"),
|
||||
|
|
@ -124,7 +126,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_consumed": _fmt_pct(avg_ring_pct / ring_size) if avg_ring_pct else "\u2014",
|
||||
"avg_ring_consumed": _fmt_pct(ring_products_seen / ring_size),
|
||||
"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