Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor dim_orgs and incorporate changes into sales_sync #156

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions models/core_/dim__orgs.sql
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,18 @@ WITH orgs AS (
org_id
, event_timestamp AS sub_created_at
, plan as sub_plan
, price as sub_price
, coalesce(price, 0) as sub_price
FROM {{ ref('subscription__created') }}
)


SELECT
org_id
, created_at
, num_users
, case when num_users > 2 then 2 else num_users end as num_users
, sub_created_at
, sub_plan
, sub_price
, case when num_users = 1 then 'Individual' else sub_plan end as sub_plan
, case when sub_price = 99 then 100 else sub_price end as sub_price
FROM orgs
LEFT JOIN user_count USING (org_id)
LEFT JOIN subscriptions USING (org_id)
1 change: 1 addition & 0 deletions models/core_/dim__users.sql
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ WITH users AS (
SELECT
user_id
FROM users
WHERE 1 = 1
2 changes: 1 addition & 1 deletion models/syncs_/sales__sync.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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
WHERE sub_plan IS NULL or sub_plan = 'Individual'
)

, final AS (
Expand Down
Loading