diff --git a/src/dbt/kipptaf/models/extracts/deanslist/rpt_deanslist__student_misc.sql b/src/dbt/kipptaf/models/extracts/deanslist/rpt_deanslist__student_misc.sql index 5c69fd9079..b0c02a515b 100644 --- a/src/dbt/kipptaf/models/extracts/deanslist/rpt_deanslist__student_misc.sql +++ b/src/dbt/kipptaf/models/extracts/deanslist/rpt_deanslist__student_misc.sql @@ -20,7 +20,7 @@ with select co.studentid, co.student_number, - co.state_studentnumber as sid, + co.state_studentnumber as `SID`, co.advisory_name as team, co.home_phone, co.contact_1_name as parent1_name, @@ -60,7 +60,7 @@ with ktc.contact_owner_phone as ktc_counselor_phone, ktc.contact_owner_email as ktc_counselor_email, - gpa.gpa_y1, + gpa.`GPA_Y1`, gpa.gpa_term, if(co.schoolid = 999999, ug.schoolid, co.schoolid) as schoolid, diff --git a/src/dbt/kipptaf/models/extracts/deanslist/rpt_deanslist__transcript_gpas.sql b/src/dbt/kipptaf/models/extracts/deanslist/rpt_deanslist__transcript_gpas.sql index d9271d651d..9ad7142084 100644 --- a/src/dbt/kipptaf/models/extracts/deanslist/rpt_deanslist__transcript_gpas.sql +++ b/src/dbt/kipptaf/models/extracts/deanslist/rpt_deanslist__transcript_gpas.sql @@ -38,8 +38,8 @@ with select student_number, academic_year, - round(weighted_points / credit_hours, 2) as gpa_y1_weighted, - round(unweighted_points / credit_hours, 2) as gpa_y1_unweighted, + round(weighted_points / credit_hours, 2) as `GPA_Y1_weighted`, + round(unweighted_points / credit_hours, 2) as `GPA_Y1_unweighted`, from points_rollup union all @@ -49,8 +49,8 @@ select null as academic_year, - sg.cumulative_y1_gpa as gpa_y1_weighted, - sg.cumulative_y1_gpa_unweighted as gpa_y1_unweighted, + sg.cumulative_y1_gpa as `GPA_Y1_weighted`, + sg.cumulative_y1_gpa_unweighted as `GPA_Y1_unweighted`, from {{ ref("base_powerschool__student_enrollments") }} as co inner join {{ ref("int_powerschool__gpa_cumulative") }} as sg diff --git a/src/dbt/kipptaf/models/extracts/deanslist/rpt_deanslist__transcript_grades.sql b/src/dbt/kipptaf/models/extracts/deanslist/rpt_deanslist__transcript_grades.sql index cc3eaab1eb..7b55970184 100644 --- a/src/dbt/kipptaf/models/extracts/deanslist/rpt_deanslist__transcript_grades.sql +++ b/src/dbt/kipptaf/models/extracts/deanslist/rpt_deanslist__transcript_grades.sql @@ -10,12 +10,12 @@ with sg.earnedcrhrs as credit_hours, sg.percent as y1_grade_percent, sg.grade as y1_grade_letter, - case - when sg.schoolname = 'KIPP Newark Collegiate Academy' - then 'Newark Collegiate Academy' - else sg.schoolname - end as schoolname, sg.storecode as term, + if( + sg.schoolname = 'KIPP Newark Collegiate Academy', + 'Newark Collegiate Academy', + sg.schoolname + ) as schoolname, 1 as is_stored, from {{ ref("stg_powerschool__storedgrades") }} as sg @@ -40,13 +40,14 @@ with fg.y1_percent_grade_adjusted as y1_grade_percent, fg.y1_letter_grade as y1_grade_letter, + 'Y1' as term, + if( sch.name = 'KIPP Newark Collegiate Academy', 'Newark Collegiate Academy', sch.name ) as schoolname, - 'Y1' as term, 0 as is_stored, from {{ ref("stg_powerschool__students") }} as s inner join diff --git a/src/dbt/kipptaf/models/kippadb/intermediate/int_kippadb__contact_note_rollup.sql b/src/dbt/kipptaf/models/kippadb/intermediate/int_kippadb__contact_note_rollup.sql index 448aaf5f2c..8775e3057c 100644 --- a/src/dbt/kipptaf/models/kippadb/intermediate/int_kippadb__contact_note_rollup.sql +++ b/src/dbt/kipptaf/models/kippadb/intermediate/int_kippadb__contact_note_rollup.sql @@ -15,7 +15,7 @@ with when `subject` = 'Tuition Deposit Not Required' then 'TD_NR' when `subject` like 'Advising Session%' - then 'AS' + then 'AS' || regexp_extract(subject, r'Advising\s*Session\s*#?\s*(\d+)') when `subject` like 'Grad Plan%' then 'GP' when regexp_contains(`subject`, r'SC\d') @@ -28,6 +28,7 @@ with then regexp_extract(`subject`, r'Q\d\s?(SM\d)') when `subject` like '%HV' then 'HV' + else subject end as contact_subject, case when regexp_contains(`subject`, r'Q\d') diff --git a/src/dbt/kipptaf/models/kippadb/staging/stg_kippadb__gpa.sql b/src/dbt/kipptaf/models/kippadb/staging/stg_kippadb__gpa.sql index 0cde132b1f..0ad6d9a58a 100644 --- a/src/dbt/kipptaf/models/kippadb/staging/stg_kippadb__gpa.sql +++ b/src/dbt/kipptaf/models/kippadb/staging/stg_kippadb__gpa.sql @@ -1,57 +1,58 @@ with gpa_clean as ( select - id as `id`, - `name` as `name`, - createdbyid as `created_by_id`, - createddate as `created_date`, - lastmodifiedbyid as `last_modified_by_id`, - lastmodifieddate as `last_modified_date`, - recordtypeid as `record_type_id`, - systemmodstamp as `system_modstamp`, - academic_status__c as `academic_status`, - college_standing__c as `college_standing`, - college_term__c as `college_term`, - credits__c as `credits`, - credits_in_major__c as `credits_in_major`, - credits_required_for_graduation__c as `credits_required_for_graduation`, - cumulative_credits_attempted__c as `cumulative_credits_attempted`, - cumulative_credits_earned__c as `cumulative_credits_earned`, - enrollment__c as `enrollment`, - gpa__c as `gpa`, - gpa_count__c as `gpa_count`, - gpa_in_major__c as `gpa_in_major`, - major__c as `major`, - major_area__c as `major_area`, - major_cumulative_credits_attempted__c + src.id as `id`, + src.`name` as `name`, + src.createdbyid as `created_by_id`, + src.createddate as `created_date`, + src.lastmodifiedbyid as `last_modified_by_id`, + src.lastmodifieddate as `last_modified_date`, + src.recordtypeid as `record_type_id`, + src.systemmodstamp as `system_modstamp`, + src.academic_status__c as `academic_status`, + src.college_standing__c as `college_standing`, + src.college_term__c as `college_term`, + src.credits__c as `credits`, + src.credits_in_major__c as `credits_in_major`, + src.credits_required_for_graduation__c as `credits_required_for_graduation`, + src.cumulative_credits_attempted__c as `cumulative_credits_attempted`, + src.cumulative_credits_earned__c as `cumulative_credits_earned`, + src.enrollment__c as `enrollment`, + src.gpa__c as `gpa`, + src.gpa_count__c as `gpa_count`, + src.gpa_in_major__c as `gpa_in_major`, + src.major__c as `major`, + src.major_area__c as `major_area`, + src.major_cumulative_credits_attempted__c as `major_cumulative_credits_attempted`, - major_cumulative_credits_earned__c as `major_cumulative_credits_earned`, - major_cumulative_gpa__c as `major_cumulative_gpa`, - major_declared__c as `major_declared`, - major_semester_credits_attempted__c as `major_semester_credits_attempted`, - major_semester_credits_earned__c as `major_semester_credits_earned`, - major_semester_gpa__c as `major_semester_gpa`, - scale__c as `scale`, - semester_credits_attempted__c as `semester_credits_attempted`, - semester_credits_earned__c as `semester_credits_earned`, - semester_gpa__c as `semester_gpa`, - source__c as `source`, - student__c as `student`, - term__c as `term`, - term_number__c as `term_number`, - term_type__c as `term_type`, - time_period__c as `time_period`, - time_period_sort_order__c as `time_period_sort_order`, - transcript_date__c as `transcript_date`, - type__c as `type`, - from {{ source("kippadb", "gpa") }} + src.major_cumulative_credits_earned__c as `major_cumulative_credits_earned`, + src.major_cumulative_gpa__c as `major_cumulative_gpa`, + src.major_declared__c as `major_declared`, + src.major_semester_credits_attempted__c + as `major_semester_credits_attempted`, + src.major_semester_credits_earned__c as `major_semester_credits_earned`, + src.major_semester_gpa__c as `major_semester_gpa`, + src.scale__c as `scale`, + src.semester_credits_attempted__c as `semester_credits_attempted`, + src.semester_credits_earned__c as `semester_credits_earned`, + src.semester_gpa__c as `semester_gpa`, + src.source__c as `source`, + src.student__c as `student`, + src.term__c as `term`, + src.term_number__c as `term_number`, + src.term_type__c as `term_type`, + src.time_period__c as `time_period`, + src.time_period_sort_order__c as `time_period_sort_order`, + src.transcript_date__c as `transcript_date`, + src.type__c as `type`, + from {{ source("kippadb", "gpa") }} as src where not isdeleted ) select *, case - extract(month from transcript_date) when 1 then 'fall' when 5 then 'spr' + extract(month from transcript_date) when 1 then 'Fall' when 5 then 'Spring' end as semester, {{ teamster_utils.date_to_fiscal_year( diff --git a/src/dbt/kipptaf/models/surveys/intermediate/int_surveys__response_identifiers.sql b/src/dbt/kipptaf/models/surveys/intermediate/int_surveys__response_identifiers.sql index d0bfaee0eb..3a96a317f9 100644 --- a/src/dbt/kipptaf/models/surveys/intermediate/int_surveys__response_identifiers.sql +++ b/src/dbt/kipptaf/models/surveys/intermediate/int_surveys__response_identifiers.sql @@ -88,16 +88,6 @@ with ) ), - identifier_responses_deduplicate as ( - {{ - dbt_utils.deduplicate( - relation="identifier_responses_pivot", - partition_by="survey_id, respondent_employee_number, subject_employee_number, campaign_fiscal_year, campaign_name", - order_by="response_date_submitted desc", - ) - }} - ), - response_clean as ( select rp.survey_id, @@ -121,7 +111,17 @@ with ifnull( rp.respondent_employee_number, ab.respondent_employee_number ) as respondent_employee_number, - from identifier_responses_deduplicate as rp + + row_number() over ( + partition by + rp.survey_id, + rp.respondent_employee_number, + rp.subject_employee_number, + rp.campaign_fiscal_year, + rp.campaign_name + order by rp.response_date_submitted desc + ) as rn_survey_response_campaign_desc, + from identifier_responses_pivot as rp left join {{ source("alchemer", "src_alchemer__response_id_override") }} as ab on rp.survey_id = ab.survey_id @@ -142,6 +142,7 @@ select rc.subject_employee_number, rc.respondent_employee_number, rc.respondent_salesforce_id, + rc.rn_survey_response_campaign_desc, resp.preferred_name_lastfirst as respondent_preferred_name_lastfirst, resp.worker_id as respondent_adp_worker_id,