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

fix/dim_teachers #65

Merged
merged 3 commits into from
Jan 29, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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: 5 additions & 3 deletions dbt/models/marts/teachers/dim_teachers.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@ with
teachers as (
select
{{ dbt_utils.star(
from=ref('stg_dashboard__users'),
from=ref('stg_dashboard_pii__users'),
except=["user_id",
"is_urg",
"student_id"]) }}
from {{ ref('stg_dashboard__users') }}
"student_id",
"birthday",
"school_info_id"]) }}
from {{ ref('stg_dashboard_pii__users') }}
where teacher_id is not null
),

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ with
source as (
select *
from {{ source('dashboard', 'followers') }}
where deleted_at is null
),

renamed as (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,27 @@ with
source as (
select *
from {{ source('dashboard_pii', 'users') }}
where not deleted_at
),

renamed as (
select
id as user_id,
studio_person_id,
email,
sign_in_count,
current_sign_in_at,
last_sign_in_at,
created_at,
updated_at,
-- username,
deleted_at,
username,
provider,
uid,
admin,
-- gender,
-- name,
gender,
name,
locale,
-- birthday,
birthday,
user_type,
school,
full_address,
Expand All @@ -32,7 +33,7 @@ renamed as (
invited_by_id,
invited_by_type,
terms_of_service_version,
urm as is_urm,
urm as is_urg,
-- races,
primary_contact_info_id

Expand Down
52 changes: 50 additions & 2 deletions dbt/models/staging/dashboard_pii/stg_dashboard_pii__users.sql
Original file line number Diff line number Diff line change
@@ -1,8 +1,56 @@
{{
config(
materialized='incremental',
unique_key='user_id')
}}

with
users as (
select *
select *
from {{ ref('base_dashboard_pii__users') }}
where is_active

{% if is_incremental() %}

and updated_at > (select max(updated_at) from {{ this }} )

{% endif %}
),

renamed as (
select
-- PK
user_id,

-- FK's
case when user_type = 'student' then user_id end as student_id,
case when user_type = 'teacher' then user_id end as teacher_id,
studio_person_id,

--PII
email,

-- user info
user_type,
datediff(year,birthday,current_date ) as age_years,
nullif(lower(gender),'') as gender,
is_urg,

-- misc.
locale,
sign_in_count,
school_info_id,
total_lines,

-- dates
current_sign_in_at,
last_sign_in_at,
created_at,
updated_at,
deleted_at,
purged_at
from users
)

select *
from users
from renamed