From 85fadb9283b551de67f16639625e29d61ff92f9e Mon Sep 17 00:00:00 2001 From: Sung Won Chung Date: Mon, 5 Feb 2024 14:48:14 -0800 Subject: [PATCH] mimic demo main branch --- models/core/dim_orgs.sql | 14 ++++++-------- models/syncs/sales_sync.sql | 2 +- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/models/core/dim_orgs.sql b/models/core/dim_orgs.sql index d3ec01c..a2fc2f6 100644 --- a/models/core/dim_orgs.sql +++ b/models/core/dim_orgs.sql @@ -2,10 +2,9 @@ WITH orgs AS ( --prod SELECT org_id - , org_name - , employee_range - , created_at - FROM {{ ref('org_created') }} + , MIN(event_timestamp) AS created_at + FROM {{ ref('signed_in') }} + GROUP BY 1 -- --dev -- SELECT @@ -29,7 +28,7 @@ WITH orgs AS ( org_id , event_timestamp AS sub_created_at , plan as sub_plan - , coalesce(price, 0) as sub_price + , price as sub_price FROM {{ ref('subscription_created') }} ) @@ -37,11 +36,10 @@ WITH orgs AS ( SELECT org_id , created_at - {# , num_users #} + , num_users , sub_created_at - , case when num_users = 1 then 'Individual' else sub_plan end as sub_plan + , sub_plan , sub_price - , 1 as new_column FROM orgs LEFT JOIN user_count USING (org_id) LEFT JOIN subscriptions USING (org_id) diff --git a/models/syncs/sales_sync.sql b/models/syncs/sales_sync.sql index 2567aac..ff10d8c 100644 --- a/models/syncs/sales_sync.sql +++ b/models/syncs/sales_sync.sql @@ -3,7 +3,7 @@ WITH org_events AS ( * FROM {{ ref('dim_orgs') }} LEFT JOIN {{ ref('feature_used') }} USING (org_id) - WHERE sub_plan IS NULL or sub_plan = 'Individual' + WHERE sub_plan IS NULL ) , final AS (