Skip to content

Commit b39bc1e

Browse files
authored
Fix/add school year week to curriculum students (#306)
2 parents a0995d3 + 855d16b commit b39bc1e

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

dbt/models/marts/metrics/_metrics__models.yml

+8
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,8 @@ models:
160160
- not_null
161161
- name: week_number
162162
description: ISO week number
163+
- name: week_number_school_year
164+
description: week of the school year (starts July 1, ends June 30)
163165
- name: n_students
164166
description: number of unique students meeting at least 1+ day of curriculum (including HS). This is the number to use for reporting total curriculum students externally.
165167
- name: n_students_adj
@@ -180,6 +182,12 @@ models:
180182
description: school year to date counts for that school year for ES, adjusted to account for expected 40% anonymous. Code.org goals should use the adjusted number for ES. External reporting should not use this number.
181183
data_tests:
182184
- not_null
185+
data_tests:
186+
- dbt_utils.unique_combination_of_columns:
187+
combination_of_columns:
188+
- country
189+
- qualifying_date
190+
183191
config:
184192
tags: ['released','reporting']
185193

dbt/models/marts/metrics/fct_daily_curriculum_student_users.sql

+12-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ This is a daily cut so that the stakeholders can see YOY changes below the schoo
77
Edit log:
88
99
2025-03-17 CK - edited to make global + replaced dssla with duca as a source of all_students data (for speed)
10+
2025-04-17 CK - edited to add school year week
1011
1112
*/
1213

@@ -60,6 +61,11 @@ with curriculum_counts as (
6061
group by 1,2
6162
)
6263

64+
, school_weeks as (
65+
select *
66+
from {{ ref('int_school_weeks') }}
67+
)
68+
6369
, date_spine as (
6470
{{ dbt_utils.date_spine(
6571
datepart="day",
@@ -142,9 +148,10 @@ with curriculum_counts as (
142148

143149
, final as (
144150
select
145-
school_year
151+
calculations.school_year
146152
, qualifying_date
147153
, date_part(week, qualifying_date)::int week_number
154+
, sw.school_year_week as week_number_school_year
148155
, decode (date_part(dayofweek, qualifying_date),
149156
0, 'sun',
150157
1, 'mon',
@@ -162,6 +169,10 @@ with curriculum_counts as (
162169
, coalesce(n_students_es, 0) as n_students_es
163170
, coalesce(round(n_students_es * 1.4)::int,0) as n_students_es_adj
164171
from calculations
172+
left join school_weeks as sw
173+
on calculations.qualifying_date
174+
between sw.started_at
175+
and sw.ended_at
165176
)
166177

167178
select *

0 commit comments

Comments
 (0)