fix(admin): compter les visiteurs uniques dans le funnel non filtré
Avant la migration 0036, COUNT(id) == COUNT(DISTINCT anonymous_id) car la contrainte permettait au plus une ligne par visiteur+événement. Avec la colonne `page`, un visiteur peut produire plusieurs landing_view, donc le funnel comptait des lignes au lieu de visiteurs. Alignement sur COUNT(DISTINCT anonymous_id) comme la branche filtrée. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
c346a6cff2
commit
816c414bef
1 changed files with 3 additions and 3 deletions
|
|
@ -1,7 +1,7 @@
|
|||
from datetime import datetime, timedelta, timezone
|
||||
from uuid import UUID
|
||||
|
||||
from sqlalchemy import delete, func, select
|
||||
from sqlalchemy import delete, distinct, func, select
|
||||
from sqlalchemy.dialects.postgresql import insert
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
|
||||
|
|
@ -65,7 +65,7 @@ async def record_growth_event(
|
|||
|
||||
async def activation_dashboard(db: AsyncSession) -> dict:
|
||||
counts_rows = (await db.execute(
|
||||
select(GrowthEvent.event_name, func.count(GrowthEvent.id))
|
||||
select(GrowthEvent.event_name, func.count(distinct(GrowthEvent.anonymous_id)))
|
||||
.where(GrowthEvent.event_name.in_(FUNNEL_EVENTS))
|
||||
.group_by(GrowthEvent.event_name)
|
||||
)).all()
|
||||
|
|
@ -81,7 +81,7 @@ async def activation_dashboard(db: AsyncSession) -> dict:
|
|||
|
||||
async def segment(column):
|
||||
rows = (await db.execute(
|
||||
select(column, GrowthEvent.event_name, func.count(GrowthEvent.id))
|
||||
select(column, GrowthEvent.event_name, func.count(distinct(GrowthEvent.anonymous_id)))
|
||||
.where(GrowthEvent.event_name.in_(FUNNEL_EVENTS))
|
||||
.group_by(column, GrowthEvent.event_name)
|
||||
)).all()
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue