fix: cap session duration to 60min in engagement scoring
Some checks are pending
NordaBiz Tests / Unit & Integration Tests (push) Waiting to run
NordaBiz Tests / E2E Tests (Playwright) (push) Blocked by required conditions
NordaBiz Tests / Smoke Tests (Production) (push) Blocked by required conditions
NordaBiz Tests / Send Failure Notification (push) Blocked by required conditions

Zombie sessions (browser tab left open for days) were inflating
duration-based scores. LEAST(duration_seconds, 3600) per session
ensures only active time counts toward engagement.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Maciej Pienczyn 2026-03-10 21:09:06 +01:00
parent a583ae3386
commit 7a83719647

View File

@ -562,7 +562,7 @@ def _tab_engagement(db, start_date, days):
UserSession.user_id,
func.count(UserSession.id).label('cnt'),
func.coalesce(func.sum(UserSession.clicks_count), 0).label('clicks'),
func.coalesce(func.sum(UserSession.duration_seconds), 0).label('dur')
func.coalesce(func.sum(func.least(UserSession.duration_seconds, 3600)), 0).label('dur')
).filter(
UserSession.started_at >= start_30d,
UserSession.user_id.isnot(None),