-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bugfix/attendance calendars from bell schedules #88
Draft
sleblanc23
wants to merge
3
commits into
main
Choose a base branch
from
bugfix/att_calendars_from_bell_schedules
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
with student_school_enr as ( | ||
select * from {{ ref('fct_student_school_association') }} | ||
), | ||
student_section_enr as ( | ||
select * from {{ ref('fct_student_section_association') }} | ||
), | ||
course_section as ( | ||
select * from {{ ref('dim_course_section') }} | ||
), | ||
section_class_periods as ( | ||
select * from {{ ref('stg_ef3__sections__class_periods') }} | ||
), | ||
class_period as ( | ||
select * from {{ ref('dim_class_period') }} | ||
), | ||
bell_class_period as ( | ||
select * from {{ ref('stg_ef3__bell_schedules__class_periods') }} | ||
), | ||
bell as ( | ||
select * from {{ ref('stg_ef3__bell_schedules') }} | ||
), | ||
bell_dates as ( | ||
select * from {{ ref('stg_ef3__bell_schedules__dates') }} | ||
), | ||
school_calendar as ( | ||
select * from {{ ref('dim_school_calendar') }} | ||
), | ||
calendar_date as ( | ||
select * from {{ ref('dim_calendar_date') }} | ||
), | ||
-- Find all class dates for a student based on their bell schedules | ||
student_bell_schedule_dates as ( | ||
select distinct | ||
student_school_enr.k_student, | ||
student_school_enr.k_student_xyear, | ||
student_school_enr.k_school, | ||
student_school_enr.k_school_calendar, | ||
student_school_enr.entry_date, | ||
student_school_enr.exit_withdraw_date, | ||
bell_dates.calendar_date | ||
from student_school_enr | ||
inner join student_section_enr | ||
on student_school_enr.k_student = student_section_enr.k_student | ||
and student_school_enr.k_school = student_section_enr.k_school | ||
inner join course_section | ||
on student_section_enr.k_course_section = course_section.k_course_section | ||
inner join section_class_periods | ||
on student_section_enr.k_course_section = section_class_periods.k_course_section | ||
inner join class_period | ||
on section_class_periods.k_class_period = class_period.k_class_period | ||
inner join bell_class_period | ||
on class_period.k_class_period = bell_class_period.k_class_period | ||
inner join bell | ||
on bell_class_period.k_bell_schedule = bell.k_bell_schedule | ||
inner join bell_dates | ||
on bell.k_bell_schedule = bell_dates.k_bell_schedule | ||
-- limit to the duration of the section enrollment | ||
where bell_dates.calendar_date between student_section_enr.begin_date and student_section_enr.end_date | ||
-- limit to the duration of the school enrollment | ||
and bell_dates.calendar_date >= student_school_enr.entry_date | ||
and (bell_dates.calendar_date <= student_school_enr.exit_withdraw_date | ||
or student_school_enr.exit_withdraw_date is null) | ||
), | ||
-- Remove any non-instructional days | ||
student_class_dates as ( | ||
select | ||
student_bell_schedule_dates.k_student, | ||
student_bell_schedule_dates.k_student_xyear, | ||
student_bell_schedule_dates.k_school, | ||
calendar_date.k_calendar_date, | ||
school_calendar.tenant_code, | ||
school_calendar.school_year, | ||
student_bell_schedule_dates.entry_date, | ||
student_bell_schedule_dates.exit_withdraw_date, | ||
calendar_date.calendar_date | ||
from student_bell_schedule_dates | ||
inner join school_calendar | ||
on student_bell_schedule_dates.k_school_calendar = school_calendar.k_school_calendar | ||
inner join calendar_date | ||
on school_calendar.k_school_calendar = calendar_date.k_school_calendar | ||
and student_bell_schedule_dates.calendar_date = calendar_date.calendar_date | ||
where calendar_date.is_school_day | ||
) | ||
select * | ||
from student_class_dates |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we need to handle nulls in end_date here