Skip to content

Commit

Permalink
feat: Add unknown count to commercial analytics
Browse files Browse the repository at this point in the history
  • Loading branch information
storm1729 committed Dec 26, 2024
1 parent dc15947 commit 6803c20
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions supabase/migrations/20241226184126_add_unknown_count.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
CREATE OR REPLACE VIEW analytics_commercial_license_users_past_month
WITH (security_invoker = on) AS
SELECT
u.id AS user_id,
u.email,
u.created_at AS registration_date,
COUNT(c.id) AS call_count,
SUM(CASE WHEN c.is_reachable = 'unknown' THEN 1 ELSE 0 END) AS unknown_email_count
FROM auth.users u
JOIN calls c ON u.id = c.user_id
WHERE c.endpoint = '/v1/commercial_license_trial'
AND c.created_at >= NOW() - INTERVAL '1 month'
GROUP BY u.id, u.email, u.created_at
ORDER BY call_count DESC;

0 comments on commit 6803c20

Please sign in to comment.