From da204cdd9a702ff8903be75f2d4b385770255bde Mon Sep 17 00:00:00 2001 From: Natalia Zacipa Mejia Date: Tue, 26 Nov 2024 02:48:09 +0000 Subject: [PATCH 1/2] There's two changes in this PR: 1. Adding content_area and topic_tags to dim_user_levels 2. Change to staging scripts layer to define content_area as 'other' when null to make it consistent with the logic we use for course_names where nulls are defined as 'other' --- dbt/models/marts/users/dim_user_levels.sql | 2 ++ .../staging/dashboard/stg_dashboard__scripts.sql | 13 +++++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/dbt/models/marts/users/dim_user_levels.sql b/dbt/models/marts/users/dim_user_levels.sql index 07b25212..7939a216 100644 --- a/dbt/models/marts/users/dim_user_levels.sql +++ b/dbt/models/marts/users/dim_user_levels.sql @@ -50,8 +50,10 @@ combined as ( cs.level_script_id, -- courses data + cs.content_area, cs.course_name, cs.is_active_student_course, + cs.topic_tags, -- aggs usl.time_spent_minutes, diff --git a/dbt/models/staging/dashboard/stg_dashboard__scripts.sql b/dbt/models/staging/dashboard/stg_dashboard__scripts.sql index 0555e2ff..e0c565b5 100644 --- a/dbt/models/staging/dashboard/stg_dashboard__scripts.sql +++ b/dbt/models/staging/dashboard/stg_dashboard__scripts.sql @@ -31,11 +31,16 @@ final as ( version_year, is_standalone, unit, - nullif(content_area,'') as content_area, - nullif(topic_tags_list,'') as topic_tags, + case + when course_name = 'hoc' + then 'hoc' -- If course_name is HOC, content area is HOC too + when nullif(content_area,'') is null then 'other' -- If content area is null then 'other' to align with course_name + else nullif(content_area,'') + end as content_area, + nullif(topic_tags_list,'') as topic_tags, created_at, updated_at from renamed ) -select * -from final +select * +from final \ No newline at end of file From 7ca522cc5278d3a6be412394dce3b2fbe3d6ac43 Mon Sep 17 00:00:00 2001 From: Natalia Zacipa Mejia Date: Tue, 26 Nov 2024 20:18:38 +0000 Subject: [PATCH 2/2] update to simplify content_area logic --- dbt/models/staging/dashboard/stg_dashboard__scripts.sql | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/dbt/models/staging/dashboard/stg_dashboard__scripts.sql b/dbt/models/staging/dashboard/stg_dashboard__scripts.sql index e0c565b5..c23f3b2d 100644 --- a/dbt/models/staging/dashboard/stg_dashboard__scripts.sql +++ b/dbt/models/staging/dashboard/stg_dashboard__scripts.sql @@ -34,8 +34,9 @@ final as ( case when course_name = 'hoc' then 'hoc' -- If course_name is HOC, content area is HOC too - when nullif(content_area,'') is null then 'other' -- If content area is null then 'other' to align with course_name - else nullif(content_area,'') + when content_area is null then 'other' -- If content area is null then 'other' to align with course_name + when content_area = '' then 'other' -- If content area is empty then 'other' to align with course_name + else content_area end as content_area, nullif(topic_tags_list,'') as topic_tags, created_at,