Skip to content

Commit 5a0c360

Browse files
committed
added 365 implementation data [ci skip]
1 parent d4651f2 commit 5a0c360

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

aws/redshift/tables/regional_partner_stats_csf.sql

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
-- PLAN for adding CSF data
2+
-- add data on the facilitator, district sponsorship, workshop size, day of week, time of year
3+
-- create separate csf_facilitator csf_workshops table to connect to this one?
4+
15
--CHANGES
26
-- addition of school years beyond 2017 -- includes teaching data from the same year they were trained and any subsequent years
37
-- removed 'location'
@@ -35,6 +39,24 @@ select
3539
script_name
3640
from analysis.csf_started_teachers
3741
),
42+
implementation_365 as
43+
(select
44+
tt.user_id,
45+
date_part(month, trained_at) month_trained,
46+
date_part(dayofweek, trained_at) day_of_week,
47+
min(datediff(day, tt.trained_at, st.started_at)) as days_to_start,
48+
min(datediff(day, tt.trained_at, ct.completed_at)) as days_to_complete,
49+
CASE WHEN days_to_start < 0 then 1 else 0 end as started_before_training,
50+
CASE WHEN days_to_complete < 0 then 1 else 0 end as completed_before_training,
51+
CASE WHEN days_to_start <= 365 and started_before_training = 0 then 1 else 0 end as started_365,
52+
CASE WHEN days_to_complete <= 365 and completed_before_training = 0 then 1 else 0 end as completed_365,
53+
CASE WHEN days_to_start <= 365 then 1 else 0 end as started_365_or_before,
54+
CASE WHEN days_to_complete <= 365 then 1 else 0 end as completed_365_or_before
55+
from csf_teachers_trained tt
56+
left join csf_started_teachers st on st.user_id = tt.user_id
57+
left join csf_completed_teachers ct on ct.user_id = tt.user_id
58+
group by 1, 2, 3
59+
),
3860
pd_enrollments_with_year as
3961
(
4062
select pd_workshop_id, first_name, last_name, email, user_id, school_year
@@ -63,6 +85,16 @@ pd_facilitators as
6385
FIRST_VALUE(pde.email) OVER (PARTITION BY d.user_id ORDER BY (CASE WHEN pde.email IS NULL THEN 1 ELSE 2 END), pde.pd_workshop_id DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) as email,
6486
'CS Fundamentals'::varchar as course,
6587
sy.school_year as school_year_trained,
88+
month_trained,
89+
day_of_week,
90+
days_to_start,
91+
days_to_complete,
92+
started_before_training,
93+
completed_before_training,
94+
started_365,
95+
completed_365,
96+
started_365_or_before,
97+
completed_365_or_before,
6698
s.school_year as school_year_taught,
6799
s.script_name,
68100
CASE WHEN rp.name is null THEN 'No Partner' ELSE rp.name END as regional_partner_name,
@@ -128,6 +160,8 @@ pd_facilitators as
128160
ON c.user_id = d.user_id
129161
AND c.script_name = s.script_name
130162
AND c.school_year = s.school_year
163+
LEFT JOIN implementation_365 i
164+
ON i.user_id = d.user_id
131165
LEFT JOIN analysis.teacher_most_progress_csf tmp
132166
ON tmp.user_id = d.user_id
133167
and tmp.script_name = s.script_name

0 commit comments

Comments
 (0)