Skip to content

Commit

Permalink
Merge pull request #23396 from code-dot-org/staging
Browse files Browse the repository at this point in the history
DTT (Staging > Test) [robo-dtt]
  • Loading branch information
deploy-code-org committed Jun 28, 2018
2 parents 69ee3c2 + 8ec4f3a commit fed9c46
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 312 deletions.
4 changes: 0 additions & 4 deletions aws/redshift/playbooks/regional_partner_reporting.yml.erb
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@ steps:
file: tables/quarterly_workshop_attendance.sql
- name: csf_workshop_attendance
file: tables/csf_workshop_attendance.sql
- name: csf_workshop_attendance
file: tables/csf_workshop_attendance.sql
- name: csf_workshops
file: tables/csf_workshops.sql
- name: student-activity-csf
file: tables/student_activity_csf.sql
- name: student-activity-csp-csd
Expand Down
143 changes: 0 additions & 143 deletions aws/redshift/tables/csf_attendance.sql

This file was deleted.

29 changes: 16 additions & 13 deletions aws/redshift/tables/csf_workshop_attendance.sql
Original file line number Diff line number Diff line change
Expand Up @@ -90,24 +90,26 @@ FROM sections_geos
pdw.course as course,
pdw.id AS workshop_id, -- section_id in the other table (below)
CASE WHEN subject in ('Intro Workshop', 'Intro') then 'Intro Workshop' ELSE pdw.subject END as subject,
pds.started_at as started_at,
min(pds.start) as workshop_date,
CASE WHEN pdw.regional_partner_id IS NOT NULL THEN 1 ELSE 0 END AS trained_by_regional_partner,
coalesce (pdw.regional_partner_id, rpm.regional_partner_id) AS regional_partner_id,
sy.school_year
FROM dashboard_production_pii.pd_enrollments pde
JOIN dashboard_production_pii.pd_attendances pda
ON pda.pd_enrollment_id = pde.id
JOIN dashboard_production_pii.pd_workshops pdw
ON pdw.id = pde.pd_workshop_id
JOIN dashboard_production_pii.pd_sessions pds
ON pds.pd_workshop_id = pdw.id
JOIN analysis.training_school_years sy ON pds.start BETWEEN sy.started_at AND sy.ended_at
JOIN workshop_state_zip wsz
sy.school_year,
min(CASE WHEN pds.start < DATEADD(day,-3,GETDATE()) and pda.id is null then 1 else 0 END as not_attended)
FROM dashboard_production_pii.pd_workshops pdw
JOIN dashboard_production_pii.pd_sessions pds
ON pdw.id = pds.pd_workshop_id
LEFT JOIN dashboard_production_pii.pd_enrollments pde
ON pdw.id = pde.pd_workshop_id
LEFT JOIN dashboard_production_pii.pd_attendances pda
ON pde.id = pda.pd_enrollment_id
LEFT JOIN analysis.training_school_years sy ON pds.start BETWEEN sy.started_at AND sy.ended_at
LEFT JOIN workshop_state_zip wsz
ON wsz.id = pdw.id
LEFT JOIN dashboard_production_pii.pd_regional_partner_mappings rpm
LEFT JOIN dashboard_production_pii.pd_regional_partner_mappings rpm
ON rpm.state = wsz.state OR rpm.zip_code = wsz.zip
WHERE pdw.course = 'CS Fundamentals'
AND pdw.subject IN ( 'Intro Workshop', 'Intro', 'Deep Dive Workshop')
group by 1, 2, 3, 5, 6, 7

UNION ALL

Expand All @@ -118,7 +120,8 @@ UNION ALL
se.created_at as started_at,
0 AS trained_by_regional_partner,
rpm.regional_partner_id AS regional_partner_id,
sy.school_year
sy.school_year,
0 as not_attended
FROM dashboard_production.followers f
JOIN dashboard_production.sections se
ON se.id = f.section_id AND se.section_type = 'csf_workshop'
Expand Down
136 changes: 0 additions & 136 deletions aws/redshift/tables/csf_workshops.sql

This file was deleted.

20 changes: 5 additions & 15 deletions aws/redshift/tables/regional_partner_stats_csf.sql
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,6 @@
-- right now this analysis depends primarily on the teachers_trained views, which contain one entry per person, with the corresponding 'first year trained' as the school_year
-- this means that if teachers are trained in multiple years then only info from their first year of training will get joined
-- to Mary, this does not seem ideal

-- CHANGED DEPENDENCIES
-- before using this code to update analysis.regional_partner_stats, certain other tables need to be updated, and their references updated here
-- analysis.csf_teachers_trained and analysis.csp_csd_teachers_trained need to be updated using the code in the file 'teahers_trained_updates.sql'
-- then, references in this file to public.csf_teachers_trained_test and public.csp_csd_teachers_trained_test should be replaced with 'analysis.csf_teachers_trained' and 'analysis.csp_csd_teachers_trained'
-- these are views and so do not need to be added to Github
-- similarly, the tables analysis.teacher_most_progress and analysis.student_activity need to be updated and then their references in this file replaced with the originals
-- these two need to be updated on Github

-- NOTES ON HOW TO UPDATE
-- after updating at the dependencies listed above and noted with 'PUBLIC' in the code....
Expand All @@ -34,16 +26,14 @@ csf_teachers_trained_temp as
min(school_year) as school_year,
max(regional_partner) as regional_partner,
max(regional_partner_id) as regional_partner_id,
min(trained_at) as trained_at,
min(workshop_date) as workshop_date
min(trained_at) as trained_at
from
(
SELECT
ctt.user_id,
ctt.trained_at,
regional_partner_id::int,
rp.name::varchar as regional_partner,
pds.start as workshop_date
rp.name::varchar as regional_partner
FROM
analysis.csf_teachers_trained ctt
LEFT JOIN dashboard_production_pii.pd_enrollments pde
Expand Down Expand Up @@ -126,8 +116,8 @@ pd_facilitators as
csfa.subject,
csfa.trained_by_regional_partner,
d.trained_at as trained_at,
d.workshop_date as workshop_date,
csfa.workshop_id::varchar(16) || ', '::varchar(2) || extract(month from csfa.started_at)::varchar(16) || '/'::varchar(2) || extract(day from csfa.started_at)::varchar(16) || '/'::varchar(2) || extract(year from csfa.started_at)::varchar(16) as workshop_id_year,
csfa.workshop_date as workshop_date,
extract(month from csfa.workshop_date)::varchar(16) || '/'::varchar(2) || extract(day from csfa.workshop_date)::varchar(16) || '/'::varchar(2) || extract(year from csfa.workshop_date)::varchar(16) || ', id:'::varchar(2) csfa.workshop_id::varchar(16) as workshop_id_year,
pwf.facilitator_names,
-- started and completed
case when s.user_id is not null then 1 else 0 end as started,
Expand All @@ -152,7 +142,7 @@ pd_facilitators as
ON ss_user.school_id = si_user.school_id
-- attendance
-- LEFT JOIN analysis.csf_workshop_attendance csfa -- functions mostly to get the regional partner's location info and to decide whether the person was 'trained_by_partner'
LEFT JOIN analysis.csf_attendance csfa
LEFT JOIN analysis.csf_workshop_attendance csfa
ON csfa.user_id = d.user_id
AND csfa.course = d.course
AND csfa.school_year = d.school_year
Expand Down

0 comments on commit fed9c46

Please sign in to comment.