mirror of
https://github.com/edcommonwealth/sqm-dashboards.git
synced 2026-03-08 23:18:18 -07:00
feat: add 2023-24 academic year and make sure previous year enrollment
and staffing data get loaded when missing
This commit is contained in:
parent
e203be056a
commit
6541b87e9c
4 changed files with 49 additions and 17 deletions
|
|
@ -39,6 +39,35 @@ class EnrollmentLoader
|
|||
respondent
|
||||
end
|
||||
|
||||
def self.clone_previous_year_data
|
||||
years = AcademicYear.order(:range).last(2)
|
||||
previous_year = years.first
|
||||
current_year = years.last
|
||||
respondents = []
|
||||
School.all.each do |school|
|
||||
Respondent.where(school:, academic_year: previous_year).each do |respondent|
|
||||
current_respondent = Respondent.find_or_initialize_by(school:, academic_year: current_year)
|
||||
current_respondent.pk = respondent.pk
|
||||
current_respondent.k = respondent.k
|
||||
current_respondent.one = respondent.one
|
||||
current_respondent.two = respondent.two
|
||||
current_respondent.three = respondent.three
|
||||
current_respondent.four = respondent.four
|
||||
current_respondent.five = respondent.five
|
||||
current_respondent.six = respondent.six
|
||||
current_respondent.seven = respondent.seven
|
||||
current_respondent.eight = respondent.eight
|
||||
current_respondent.nine = respondent.nine
|
||||
current_respondent.ten = respondent.ten
|
||||
current_respondent.eleven = respondent.eleven
|
||||
current_respondent.twelve = respondent.twelve
|
||||
current_respondent.total_students = respondent.total_students
|
||||
respondents << current_respondent
|
||||
end
|
||||
end
|
||||
Respondent.import respondents, batch_size: 1000, on_duplicate_key_update: [:total_teachers]
|
||||
end
|
||||
|
||||
private_class_method :create_enrollment_entry
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'csv'
|
||||
require "csv"
|
||||
|
||||
class StaffingLoader
|
||||
def self.load_data(filepath:)
|
||||
|
|
@ -51,20 +51,19 @@ class StaffingRowValues
|
|||
|
||||
def school
|
||||
@school ||= begin
|
||||
dese_id = row['DESE ID'].strip.to_i
|
||||
dese_id = row["DESE ID"].strip.to_i
|
||||
School.find_by_dese_id(dese_id)
|
||||
end
|
||||
end
|
||||
|
||||
def academic_year
|
||||
@academic_year ||= begin
|
||||
year = row['Academic Year']
|
||||
year = row["Academic Year"]
|
||||
AcademicYear.find_by_range(year)
|
||||
end
|
||||
end
|
||||
|
||||
def fte_count
|
||||
row['FTE Count']
|
||||
row["FTE Count"]
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue