Count only ACTIVE subscriptions in new-subscription analytics.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
eb1d0c68e2
commit
a44eee78b7
|
|
@ -151,13 +151,18 @@ ORDER BY d.date;
|
||||||
SELECT
|
SELECT
|
||||||
COUNT(*)::bigint AS total,
|
COUNT(*)::bigint AS total,
|
||||||
COUNT(*) FILTER (WHERE us.status = 'ACTIVE')::bigint AS active,
|
COUNT(*) FILTER (WHERE us.status = 'ACTIVE')::bigint AS active,
|
||||||
COUNT(*) FILTER (WHERE us.created_at::date = sqlc.arg('ref_date')::date)::bigint AS new_today,
|
|
||||||
COUNT(*) FILTER (
|
COUNT(*) FILTER (
|
||||||
WHERE us.created_at::date >= sqlc.arg('ref_date')::date - INTERVAL '6 days'
|
WHERE us.status = 'ACTIVE'
|
||||||
|
AND us.created_at::date = sqlc.arg('ref_date')::date
|
||||||
|
)::bigint AS new_today,
|
||||||
|
COUNT(*) FILTER (
|
||||||
|
WHERE us.status = 'ACTIVE'
|
||||||
|
AND us.created_at::date >= sqlc.arg('ref_date')::date - INTERVAL '6 days'
|
||||||
AND us.created_at::date <= sqlc.arg('ref_date')::date
|
AND us.created_at::date <= sqlc.arg('ref_date')::date
|
||||||
)::bigint AS new_this_week,
|
)::bigint AS new_this_week,
|
||||||
COUNT(*) FILTER (
|
COUNT(*) FILTER (
|
||||||
WHERE us.created_at::date >= sqlc.arg('ref_date')::date - INTERVAL '29 days'
|
WHERE us.status = 'ACTIVE'
|
||||||
|
AND us.created_at::date >= sqlc.arg('ref_date')::date - INTERVAL '29 days'
|
||||||
AND us.created_at::date <= sqlc.arg('ref_date')::date
|
AND us.created_at::date <= sqlc.arg('ref_date')::date
|
||||||
)::bigint AS new_this_month
|
)::bigint AS new_this_month
|
||||||
FROM user_subscriptions us
|
FROM user_subscriptions us
|
||||||
|
|
@ -198,6 +203,7 @@ FROM generate_series(
|
||||||
INTERVAL '1 day'
|
INTERVAL '1 day'
|
||||||
) AS d(date)
|
) AS d(date)
|
||||||
LEFT JOIN user_subscriptions us ON us.created_at::date = d.date
|
LEFT JOIN user_subscriptions us ON us.created_at::date = d.date
|
||||||
|
AND us.status = 'ACTIVE'
|
||||||
AND (sqlc.narg('range_start')::timestamptz IS NULL OR us.created_at >= sqlc.narg('range_start')::timestamptz)
|
AND (sqlc.narg('range_start')::timestamptz IS NULL OR us.created_at >= sqlc.narg('range_start')::timestamptz)
|
||||||
AND (sqlc.narg('range_end')::timestamptz IS NULL OR us.created_at < sqlc.narg('range_end')::timestamptz)
|
AND (sqlc.narg('range_end')::timestamptz IS NULL OR us.created_at < sqlc.narg('range_end')::timestamptz)
|
||||||
GROUP BY d.date
|
GROUP BY d.date
|
||||||
|
|
|
||||||
|
|
@ -331,6 +331,7 @@ FROM generate_series(
|
||||||
INTERVAL '1 day'
|
INTERVAL '1 day'
|
||||||
) AS d(date)
|
) AS d(date)
|
||||||
LEFT JOIN user_subscriptions us ON us.created_at::date = d.date
|
LEFT JOIN user_subscriptions us ON us.created_at::date = d.date
|
||||||
|
AND us.status = 'ACTIVE'
|
||||||
AND ($3::timestamptz IS NULL OR us.created_at >= $3::timestamptz)
|
AND ($3::timestamptz IS NULL OR us.created_at >= $3::timestamptz)
|
||||||
AND ($4::timestamptz IS NULL OR us.created_at < $4::timestamptz)
|
AND ($4::timestamptz IS NULL OR us.created_at < $4::timestamptz)
|
||||||
GROUP BY d.date
|
GROUP BY d.date
|
||||||
|
|
@ -1410,13 +1411,18 @@ const AnalyticsSubscriptionsSummary = `-- name: AnalyticsSubscriptionsSummary :o
|
||||||
SELECT
|
SELECT
|
||||||
COUNT(*)::bigint AS total,
|
COUNT(*)::bigint AS total,
|
||||||
COUNT(*) FILTER (WHERE us.status = 'ACTIVE')::bigint AS active,
|
COUNT(*) FILTER (WHERE us.status = 'ACTIVE')::bigint AS active,
|
||||||
COUNT(*) FILTER (WHERE us.created_at::date = $1::date)::bigint AS new_today,
|
|
||||||
COUNT(*) FILTER (
|
COUNT(*) FILTER (
|
||||||
WHERE us.created_at::date >= $1::date - INTERVAL '6 days'
|
WHERE us.status = 'ACTIVE'
|
||||||
|
AND us.created_at::date = $1::date
|
||||||
|
)::bigint AS new_today,
|
||||||
|
COUNT(*) FILTER (
|
||||||
|
WHERE us.status = 'ACTIVE'
|
||||||
|
AND us.created_at::date >= $1::date - INTERVAL '6 days'
|
||||||
AND us.created_at::date <= $1::date
|
AND us.created_at::date <= $1::date
|
||||||
)::bigint AS new_this_week,
|
)::bigint AS new_this_week,
|
||||||
COUNT(*) FILTER (
|
COUNT(*) FILTER (
|
||||||
WHERE us.created_at::date >= $1::date - INTERVAL '29 days'
|
WHERE us.status = 'ACTIVE'
|
||||||
|
AND us.created_at::date >= $1::date - INTERVAL '29 days'
|
||||||
AND us.created_at::date <= $1::date
|
AND us.created_at::date <= $1::date
|
||||||
)::bigint AS new_this_month
|
)::bigint AS new_this_month
|
||||||
FROM user_subscriptions us
|
FROM user_subscriptions us
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user