Skip to content

Commit

Permalink
Adhoc/add cap to users (#159)
Browse files Browse the repository at this point in the history
  • Loading branch information
coryamanda authored Aug 20, 2024
2 parents 8a10882 + 515cd20 commit 56c2286
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 11 deletions.
6 changes: 6 additions & 0 deletions dbt/models/marts/students/_students__models.yml
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,12 @@ models:
- name: is_international
description: 1 if last activity was outside the US, 0 otherwise

- name: cap_status
description: child account policy tag; only relevant for students (options are 'grace period', 'locked_out', 'permission_granted')

- name: cap_status_date
description: child account policy tag; date the status is set

- name: school_id
description: school association of student
config:
Expand Down
4 changes: 2 additions & 2 deletions dbt/models/marts/students/dim_students.sql
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ school_years as (
final as (
select
students.*,
sy.school_year as created_at_school_year
sy.school_year as created_at_school_year
from students
left join school_years as sy
left join school_years as sy
on students.created_at
between sy.started_at
and sy.ended_at )
Expand Down
39 changes: 32 additions & 7 deletions dbt/models/marts/teachers/dim_teachers.sql
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
with
teachers as (
select *
select *
from {{ ref('dim_users')}}
where user_type = 'teacher'
),
Expand Down Expand Up @@ -28,21 +28,46 @@ teacher_schools as (
si.school_id,
rank () over (
partition by teachers.user_id
order by usi.ended_at desc) as rnk
order by usi.ended_at desc) as rnk
from teachers
left join user_school_infos as usi
left join user_school_infos as usi
on usi.user_id = teachers.user_id
left join school_infos as si
left join school_infos as si
on si.school_info_id = usi.school_info_id
),

--excludes student_id, cap_status, and cap_status_date from dim_users
final as (
select
teachers.*,
teachers.user_id,
teachers.teacher_id,
teachers.user_type,
teachers.studio_person_id,
teachers.school_info_id,
teachers.is_urg,
teachers.gender,
teachers.locale,
teachers.birthday,
teachers.sign_in_count,
teachers.total_lines,
teachers.current_sign_in_at,
teachers.last_sign_in_at,
teachers.created_at,
teachers.updated_at,
teachers.deleted_at,
teachers.purged_at,
teachers.teacher_email,
teachers.races,
teachers.race_group,
teachers.gender_group,
teachers.self_reported_state,
teachers.country,
teachers.us_intl,
teachers.is_international,
ts.school_id,
school_years.school_year as created_at_school_year
school_years.school_year as created_at_school_year
from teachers
inner join teacher_schools as ts
inner join teacher_schools as ts
on teachers.user_id = ts.user_id
and ts.rnk = 1
inner join school_years
Expand Down
7 changes: 7 additions & 0 deletions dbt/models/marts/users/_users__models.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,13 @@ models:
description: gender categorization column
tags:
- contains_pii

- name: cap_status
description: child account policy tag; only relevant for students (options are 'grace period', 'locked_out', 'permission_granted')

- name: cap_status_date
description: child account policy tag;

config:
tags: ['released']

Expand Down
1 change: 1 addition & 0 deletions dbt/models/marts/users/dim_users.sql
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ final as (
ug.country,
ug.us_intl,
ug.is_international

from users
left join users_pii
on users.user_id = users_pii.user_id
Expand Down
4 changes: 3 additions & 1 deletion dbt/models/staging/dashboard/base/base_dashboard__users.sql
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ renamed as (
purged_at,
urm as is_urg,
races,
primary_contact_info_id
primary_contact_info_id,
cap_status,
cap_status_date
from source
)

Expand Down
4 changes: 3 additions & 1 deletion dbt/models/staging/dashboard/stg_dashboard__users.sql
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ renamed as (
created_at,
updated_at,
deleted_at,
purged_at
purged_at,
cap_status,
cap_status_date
from users
)

Expand Down

0 comments on commit 56c2286

Please sign in to comment.