From 5ce2933d042a7fea6a15525485543e0551725291 Mon Sep 17 00:00:00 2001 From: "allison@code.org" Date: Fri, 16 Aug 2024 20:46:02 +0000 Subject: [PATCH 1/5] adding cap status and date to dim_users and upstream models --- dbt/models/staging/dashboard/base/base_dashboard__users.sql | 4 +++- dbt/models/staging/dashboard/stg_dashboard__users.sql | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/dbt/models/staging/dashboard/base/base_dashboard__users.sql b/dbt/models/staging/dashboard/base/base_dashboard__users.sql index 0d2140de..13a6a4cf 100644 --- a/dbt/models/staging/dashboard/base/base_dashboard__users.sql +++ b/dbt/models/staging/dashboard/base/base_dashboard__users.sql @@ -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 ) diff --git a/dbt/models/staging/dashboard/stg_dashboard__users.sql b/dbt/models/staging/dashboard/stg_dashboard__users.sql index b6157064..2ee2d286 100644 --- a/dbt/models/staging/dashboard/stg_dashboard__users.sql +++ b/dbt/models/staging/dashboard/stg_dashboard__users.sql @@ -39,7 +39,9 @@ renamed as ( created_at, updated_at, deleted_at, - purged_at + purged_at, + cap_status, + cap_status_date from users ) From f80f3d5eb1f88afa6459e2998c5c73bb825df098 Mon Sep 17 00:00:00 2001 From: Cory Kind Date: Sat, 17 Aug 2024 01:05:50 +0000 Subject: [PATCH 2/5] added cap_status to the base, staging, and dim_users tables. Remaining work is to add to students and remove from teachers pending confirmation from ask_platform also add docs --- dbt/models/marts/users/dim_users.sql | 1 + dbt/models/staging/dashboard/base/base_dashboard__users.sql | 4 +++- dbt/models/staging/dashboard/stg_dashboard__users.sql | 4 +++- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/dbt/models/marts/users/dim_users.sql b/dbt/models/marts/users/dim_users.sql index 3d839640..b3e508aa 100644 --- a/dbt/models/marts/users/dim_users.sql +++ b/dbt/models/marts/users/dim_users.sql @@ -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 diff --git a/dbt/models/staging/dashboard/base/base_dashboard__users.sql b/dbt/models/staging/dashboard/base/base_dashboard__users.sql index 0d2140de..13a6a4cf 100644 --- a/dbt/models/staging/dashboard/base/base_dashboard__users.sql +++ b/dbt/models/staging/dashboard/base/base_dashboard__users.sql @@ -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 ) diff --git a/dbt/models/staging/dashboard/stg_dashboard__users.sql b/dbt/models/staging/dashboard/stg_dashboard__users.sql index b6157064..2ee2d286 100644 --- a/dbt/models/staging/dashboard/stg_dashboard__users.sql +++ b/dbt/models/staging/dashboard/stg_dashboard__users.sql @@ -39,7 +39,9 @@ renamed as ( created_at, updated_at, deleted_at, - purged_at + purged_at, + cap_status, + cap_status_date from users ) From 236178c89b300f959ecce25d4511685436c1b96a Mon Sep 17 00:00:00 2001 From: Cory Kind Date: Mon, 19 Aug 2024 04:45:52 +0000 Subject: [PATCH 3/5] adding descriptions to documentation and removing the field from dim_teachers --- .../marts/students/_students__models.yml | 6 ++++ dbt/models/marts/teachers/dim_teachers.sql | 29 +++++++++++++++++-- dbt/models/marts/users/_users__models.yml | 7 +++++ 3 files changed, 40 insertions(+), 2 deletions(-) diff --git a/dbt/models/marts/students/_students__models.yml b/dbt/models/marts/students/_students__models.yml index 51237a10..aa15688d 100644 --- a/dbt/models/marts/students/_students__models.yml +++ b/dbt/models/marts/students/_students__models.yml @@ -103,6 +103,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; + - name: school_id description: school association of student config: diff --git a/dbt/models/marts/teachers/dim_teachers.sql b/dbt/models/marts/teachers/dim_teachers.sql index d615234b..59c5c0d3 100644 --- a/dbt/models/marts/teachers/dim_teachers.sql +++ b/dbt/models/marts/teachers/dim_teachers.sql @@ -1,6 +1,6 @@ with teachers as ( - select * + select * from {{ ref('dim_users')}} where user_type = 'teacher' ), @@ -36,9 +36,34 @@ teacher_schools as ( 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 from teachers diff --git a/dbt/models/marts/users/_users__models.yml b/dbt/models/marts/users/_users__models.yml index 63ada579..252557d2 100644 --- a/dbt/models/marts/users/_users__models.yml +++ b/dbt/models/marts/users/_users__models.yml @@ -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'] From 4c6f7e63b5964446e43e51ab267a7c7cc4bf0d1b Mon Sep 17 00:00:00 2001 From: Cory Kind Date: Mon, 19 Aug 2024 13:46:02 +0000 Subject: [PATCH 4/5] adding explanation to date field --- dbt/models/marts/students/_students__models.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dbt/models/marts/students/_students__models.yml b/dbt/models/marts/students/_students__models.yml index aa15688d..bdd8bf8d 100644 --- a/dbt/models/marts/students/_students__models.yml +++ b/dbt/models/marts/students/_students__models.yml @@ -107,7 +107,7 @@ models: 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; + description: child account policy tag; date the status is set - name: school_id description: school association of student From 33d4a5d59dd078913eeff2a9bf9d5a5cc681bc6e Mon Sep 17 00:00:00 2001 From: "allison@code.org" Date: Mon, 19 Aug 2024 17:49:06 +0000 Subject: [PATCH 5/5] small formatting changes --- dbt/models/marts/students/dim_students.sql | 4 ++-- dbt/models/marts/teachers/dim_teachers.sql | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/dbt/models/marts/students/dim_students.sql b/dbt/models/marts/students/dim_students.sql index d1e5ca74..70b18d60 100644 --- a/dbt/models/marts/students/dim_students.sql +++ b/dbt/models/marts/students/dim_students.sql @@ -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 ) diff --git a/dbt/models/marts/teachers/dim_teachers.sql b/dbt/models/marts/teachers/dim_teachers.sql index 59c5c0d3..d018f6f5 100644 --- a/dbt/models/marts/teachers/dim_teachers.sql +++ b/dbt/models/marts/teachers/dim_teachers.sql @@ -28,11 +28,11 @@ 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 ), @@ -65,9 +65,9 @@ final as ( 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