chore: fix problem with enrollment scraper

This commit is contained in:
rebuilt 2025-01-27 15:13:25 -08:00
parent 76b53ef1e4
commit 1de5d4d456
4 changed files with 3645 additions and 13 deletions

View file

@ -22,16 +22,16 @@ module Dese
end end
def student_count(filepath:, dese_id:, year:) def student_count(filepath:, dese_id:, year:)
@students ||= {} @student_count ||= {}
if @students.count == 0 if @student_count.count == 0
CSV.parse(File.read(filepath), headers: true).map do |row| CSV.parse(File.read(filepath), headers: true).map do |row|
academic_year = row['Academic Year'] academic_year = row['Academic Year']
school_id = row['DESE ID'].to_i school_id = row['School Code'].to_i
total = row['Total'].gsub(',', '').to_i total = row['Total'].gsub(',', '').to_i
@students[[school_id, academic_year]] = total @student_count[[school_id, academic_year]] = total
end end
end end
@students[[dese_id, year]] @student_count[[dese_id, year]]
end end
end end
end end

View file

@ -56,13 +56,13 @@ class SurveyItemValues
def recorded_date def recorded_date
@recorded_date ||= begin @recorded_date ||= begin
recorded_date = value_from(pattern: /Recorded\s*Date/i) recorded_date = value_from(pattern: /Recorded\s*Date/i)
date = if recorded_date.match(%r{\d+/\d+/\d+}) if recorded_date.match(%r{\d+/\d+/\d+})
Date.strptime(recorded_date, "%m/%d/%Y") Date.strptime(recorded_date, "%m/%d/%Y")
elsif recorded_date.match(/\d+-\d+-\d+(T|\s)\d+:\d+:\d+/) elsif recorded_date.match(/\d+-\d+-\d+(T|\s)\d+:\d+:\d+/)
Date.parse(recorded_date) Date.parse(recorded_date)
else else
puts "Recorded date in unknown format" puts "Recorded date in unknown format"
end end
end end
end end

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff