-
Notifications
You must be signed in to change notification settings - Fork 31
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
Chore: Added stage tables for portal pageviews #1267
base: master
Are you sure you want to change the base?
Changes from all commits
2e0cdbc
f0acfe5
3b05b3d
3473a19
1ba4685
d9d1475
8e06fc1
76e37d9
e499ede
8a75f26
024e972
67d054c
71c2d47
b681562
6a9748d
3c56450
864850e
3a7ff3e
cad413a
fda7444
17a8feb
c01aa85
ac2c852
280b8dc
7794524
3d0d7c1
e5c35df
5c7cb65
e20fe5d
82e5231
5838893
3e3426c
4375545
0f171eb
5fcf837
e55f634
fe86592
8d8052c
14557c9
26ac99a
f64a115
8b5aa68
1ac6047
23427ec
b618102
0243f29
4f1d7be
fb51c91
24842b5
ddccc72
e9cbd79
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
version: 2 | ||
|
||
models: | ||
|
||
- name: int_signups_aggregated_to_users | ||
description: User signup stages, aggregated by users. | ||
|
||
columns: | ||
- name: portal_customer_id | ||
description: Customer identifier that joins to customer info coming from stripe. | ||
tests: | ||
ifoukarakis marked this conversation as resolved.
Show resolved
Hide resolved
|
||
- not_null | ||
- unique | ||
- name: account_created | ||
description: Boolean value indicating if the user created the account. | ||
- name: email_verified | ||
description: Boolean value indicating if the user verified the email address. | ||
|
||
- name: int_rudder_portal_user_mapping | ||
catalintomai marked this conversation as resolved.
Show resolved
Hide resolved
|
||
description: This table provide a list of distinct user and portal customer ID pairs with a non-null value for both IDs. | ||
|
||
columns: | ||
- name: user_id | ||
description: User ID coming from rudder events. | ||
tests: | ||
- unique | ||
- name: portal_customer_id | ||
- unique | ||
description: Customer ID in portal that joins to rudder user ID. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{{ | ||
config({ | ||
"materialized": "table" | ||
}) | ||
}} | ||
|
||
SELECT | ||
user_id, | ||
portal_customer_id, | ||
min(timestamp) as first_seen_at, | ||
max(timestamp) as last_seen_at | ||
FROM | ||
{{ ref('stg_portal_prod__identifies') }} | ||
WHERE | ||
portal_customer_id IS NOT NULL | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: use same ordering like in the |
||
-- getting values as `N/A` from portal | ||
AND portal_customer_id NOT IN ('N/A') | ||
AND user_id IS NOT NULL | ||
GROUP BY | ||
1,2 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
{{ | ||
config({ | ||
"materialized": "table" | ||
}) | ||
}} | ||
WITH rudder_portal_user_mappings as ( | ||
SELECT | ||
user_id, | ||
portal_customer_id | ||
FROM | ||
{{ ref('int_rudder_portal_user_mapping') }} | ||
), pageview_create_workspace as ( | ||
SELECT | ||
user_id, | ||
pageview_id, | ||
timestamp | ||
FROM | ||
{{ ref('stg_portal_prod__pageview_create_workspace') }} | ||
), user_signup_stages as ( | ||
SELECT | ||
portal_customer_id, | ||
-- Account is created when portal_customer_id exists | ||
true AS account_created, | ||
-- Email is verified and user is redirected to `pageview_create_workspace` screen. | ||
CASE | ||
WHEN pageview_create_workspace.pageview_id IS NOT NULL | ||
THEN TRUE | ||
ELSE FALSE | ||
END AS email_verified, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Perhaps There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. adding the |
||
timestamp | ||
FROM | ||
rudder_portal_user_mappings | ||
LEFT JOIN | ||
pageview_create_workspace | ||
ON pageview_create_workspace.user_id = rudder_portal_user_mappings.user_id | ||
) | ||
|
||
select | ||
portal_customer_id, | ||
account_created, | ||
email_verified | ||
from user_signup_stages | ||
qualify row_number() over (partition by portal_customer_id order by timestamp) = 1 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not very sure on Here's an example of two :
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
with source as ( | ||
|
||
select * from {{ source('portal_prod', 'identifies') }} | ||
|
||
), | ||
|
||
renamed as ( | ||
|
||
select | ||
user_id, | ||
coalesce(portal_customer_id,context_traits_portal_customer_id) as portal_customer_id, | ||
timestamp | ||
|
||
from source | ||
|
||
) | ||
|
||
select * from renamed |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
with source as ( | ||
|
||
select * from {{ source('portal_prod', 'pageview_create_workspace') }} | ||
|
||
), | ||
|
||
renamed as ( | ||
|
||
select | ||
id as pageview_id, | ||
user_id, | ||
event as event_table, | ||
timestamp | ||
|
||
from source | ||
|
||
) | ||
|
||
select * from renamed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A better place to place signup related models can be under the name of the team responsible for this flow. Placing them under
data_eng
feels a bit strange.