chore: fix problem with enrollment scraper

This commit is contained in:
rebuilt 2025-01-27 15:13:25 -08:00
parent 498d702d95
commit 38cf38fdb5
4 changed files with 3645 additions and 13 deletions

View file

@ -23,16 +23,16 @@ module Dese
end
def student_count(filepath:, dese_id:, year:)
@students ||= {}
if @students.count == 0
@student_count ||= {}
if @student_count.count == 0
CSV.parse(File.read(filepath), headers: true).map do |row|
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
@students[[school_id, academic_year]] = total
@student_count[[school_id, academic_year]] = total
end
end
@students[[dese_id, year]]
@student_count[[dese_id, year]]
end
end
end

View file

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

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff