-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Views for Course Utilization Dashboard (#251)
- Loading branch information
Showing
5 changed files
with
186 additions
and
35 deletions.
There are no files selected for viewing
68 changes: 68 additions & 0 deletions
68
dbt/models/reporting_views/Tableau_Dashboards/view_course_utilization_by_script_level.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
/* Created 12/09/24: Section actitity for each Script, Lesson and Level for student-facing curriculum for the three most recent school years (current and two prior) for Course Utilization dashboard in Tableau | ||
*/ | ||
|
||
with | ||
school_years as ( | ||
select * | ||
from {{ref('int_school_years')}} | ||
where sysdate-(365*1) < ended_at and sysdate > started_at -- three most recent school years (current and two prior), to change the number of years, change the multiplier | ||
) | ||
|
||
|
||
, student_activity as ( | ||
select | ||
sa.section_id | ||
, date_trunc('month',sa.activity_date) month_activity_date | ||
, sa.content_area | ||
, sa.course_name | ||
, sa.unit_name | ||
, sa.script_id | ||
, sa.level_id | ||
, sa.school_year | ||
, replace(sa.topic_tags,',survey','') as topic_tags | ||
, case when sa.topic_tags like '%survey%' then 1 else 0 end is_survey | ||
, sa.us_intl | ||
, sa.country | ||
from {{ ref('dim_student_script_level_activity') }} sa | ||
join school_years sy on sa.school_year = sy.school_year -- limit to selected school years | ||
where | ||
sa.user_type = 'student' | ||
and sa.content_area not in ('hoc', 'other') | ||
and sa.topic_tags is not null -- limiting to create a small extract to enable publishing | ||
{{ dbt_utils.group_by(12) }} -- grouping instead of select distinct to deduplicate records with better performance | ||
) | ||
|
||
, course_structure as (( | ||
select distinct | ||
cs.script_id | ||
, cs.script_name | ||
, cs.version_year | ||
, cs.topic_tags | ||
, cs.stage_name as lesson_name | ||
, cs.stage_number as lesson_number | ||
, cs.stage_number || ' - ' || cs.stage_name as lesson_number_name | ||
, cs.level_id | ||
, cs.level_name | ||
, cs.level_number | ||
, cs.level_number || ' - ' || cs.level_name as level_number_name | ||
from {{ ref('dim_course_structure')}} cs | ||
where | ||
cs.content_area not in ('hoc', 'other') | ||
)) | ||
|
||
|
||
select | ||
sa.* | ||
, cs.script_name | ||
, cs.version_year | ||
, cs.lesson_name | ||
, cs.lesson_number | ||
, cs.lesson_number_name | ||
, cs.level_name | ||
, cs.level_number | ||
, cs.level_number_name | ||
from student_activity sa | ||
join course_structure cs | ||
on sa.script_id = cs.script_id | ||
and sa.level_id = cs.level_id | ||
{{ dbt_utils.group_by(20) }} -- grouping instead of select distinct to deduplicate records with better performance |
35 changes: 35 additions & 0 deletions
35
dbt/models/reporting_views/Tableau_Dashboards/view_course_utilization_unit_combinations.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* Created 12/11/24: View with activity data for student-facing curriculum for the three most recent school years (current and two prior) for Course Utilization dashboard in Tableau | ||
*/ | ||
|
||
with | ||
school_years as ( | ||
select * | ||
from {{ref('int_school_years')}} | ||
where sysdate-(365*1) < ended_at and sysdate > started_at -- three most recent school years (current and two prior), to change the number of years, change the multiplier | ||
) | ||
|
||
|
||
, student_activity as ( | ||
select sa.* | ||
from {{ ref('dim_student_script_level_activity') }} sa | ||
join school_years sy on sa.school_year = sy.school_year -- limit to selected school years | ||
where | ||
user_type = 'student' | ||
and content_area not in ('hoc') | ||
and sa.topic_tags is not null -- limiting to create a small extract to enable publishing | ||
) | ||
|
||
|
||
|
||
select | ||
sa.section_id | ||
, sa.school_year | ||
, sa.content_area | ||
, sa.course_name | ||
, sa.us_intl | ||
, sa.country | ||
, listagg(distinct sa.unit_name,', ') within group (order by unit_name) unit_combination | ||
from student_activity sa | ||
where | ||
sa.topic_tags not like '%survey%' | ||
{{ dbt_utils.group_by(6) }} |
61 changes: 61 additions & 0 deletions
61
dbt/models/reporting_views/Tableau_Dashboards/view_course_utilization_units.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/* Created 12/09/24: View with activity data for student-facing curriculum for the three most recent school years (current and two prior) for Course Utilization dashboard in Tableau | ||
*/ | ||
|
||
with | ||
|
||
school_years as ( | ||
select * | ||
from {{ref('int_school_years')}} | ||
where sysdate-(365*1) < ended_at and sysdate > started_at -- three most recent school years (current and two prior), to change the number of years, change the multiplier | ||
) | ||
|
||
|
||
, student_activity as ( | ||
select sa.* | ||
, sy.started_at as sy_start_at | ||
from {{ ref('dim_student_script_level_activity') }} sa | ||
join school_years sy on sa.school_year = sy.school_year -- limit to selected school years | ||
where | ||
user_type = 'student' | ||
and content_area not in ('hoc') | ||
and sa.topic_tags is not null -- limiting to create a small extract to enable publishing | ||
) | ||
|
||
|
||
, schools as | ||
( | ||
select school_id | ||
, case | ||
when coalesce(dss.is_title_i,0) = 1 | ||
or coalesce(dss.frl_eligible_percent,0) > 0.4 | ||
or coalesce(dss.urg_no_tr_numerator_percent,0) > 0.3 | ||
or coalesce(dss.is_rural,0) = 1 | ||
then 1 else 0 end school_is_uu | ||
from {{ref('dim_schools')}} dss | ||
) | ||
|
||
|
||
|
||
select | ||
sa.student_id | ||
, case | ||
when date_trunc('week',sa.activity_date) < sa.sy_start_at then sa.sy_start_at -- if the start of the week falls before the start of the school year, then the start of the school year | ||
else date_trunc('week',sa.activity_date) | ||
end week_activity_date | ||
, sa.content_area | ||
, sa.course_name | ||
, sa.unit_name | ||
, sa.section_id | ||
, sa.section_teacher_id as teacher_id | ||
, sa.school_id | ||
, sa.school_year | ||
, replace(sa.topic_tags,',survey','') as topic_tags | ||
, case when sa.topic_tags like '%survey%' then 1 else 0 end is_survey | ||
, sa.us_intl | ||
, sa.country | ||
, coalesce(ss.school_is_uu,0) school_is_uu | ||
, sa.school_state | ||
|
||
from student_activity sa | ||
left join schools ss on sa.school_id = ss.school_id | ||
{{ dbt_utils.group_by(15) }} -- grouping instead of select distinct to deduplicate records with better performance |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.