Skip to content

Update dim__orgs.sql #198

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

Open
wants to merge 4 commits into
base: master-databricks
Choose a base branch
from
Open
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
31 changes: 16 additions & 15 deletions models/core_/dim__orgs.sql
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
WITH orgs AS (
--prod
SELECT
org_id
, MIN(event_timestamp) AS created_at
FROM {{ ref('signed__in') }}
GROUP BY 1

-- --dev
-- SELECT
-- org_id
-- , org_name
-- , employee_range
-- , created_at
-- FROM {{ ref('org__created') }}
-- org_id
-- , MIN(event_timestamp) AS created_at
-- FROM {{ ref('signed__in') }}
-- GROUP BY 1

--dev
SELECT
org_id
, org_name
, employee_range
, created_at
FROM {{ ref('org__created') }}
)

, user_count AS (
Expand All @@ -36,10 +36,11 @@ WITH orgs AS (
SELECT
orgs.org_id
, created_at
, num_users
, case when num_users > 4 then 4 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 101 else sub_price end as sub_price
FROM orgs
LEFT JOIN user_count on orgs.org_id = user_count.org_id
LEFT JOIN subscriptions on orgs.org_id = subscriptions.org_id

2 changes: 1 addition & 1 deletion models/syncs_/sales__sync.sql
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ WITH org_events AS (
, b.activity
FROM {{ ref('dim__orgs') }} a
LEFT JOIN {{ ref('feature__used') }} b on a.org_id = b.org_id
WHERE sub_plan IS NULL
WHERE sub_plan IS NULL or sub_plan = 'Individual'
)

, final AS (
Expand Down
Loading