Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
cbini committed Aug 16, 2023
2 parents 8f4071e + 010ac7e commit 718234c
Show file tree
Hide file tree
Showing 6 changed files with 72 additions and 68 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -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')
Expand Down
89 changes: 45 additions & 44 deletions src/dbt/kipptaf/models/kippadb/staging/stg_kippadb__gpa.sql
Original file line number Diff line number Diff line change
@@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
Expand All @@ -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,
Expand Down

0 comments on commit 718234c

Please sign in to comment.