mirror of
https://github.com/edcommonwealth/sqm-dashboards.git
synced 2026-03-11 00:10:35 -07:00
update response_date to recorded_date
This commit is contained in:
parent
a30921ce06
commit
e3ae12b425
3 changed files with 16 additions and 10 deletions
|
|
@ -13,15 +13,15 @@ class SurveyItemValues
|
|||
dese_id.present?
|
||||
end
|
||||
|
||||
def response_date
|
||||
@response_date ||= begin
|
||||
def recorded_date
|
||||
@recorded_date ||= begin
|
||||
recorded_date = value_from(pattern: /Recorded\s*Date/i)
|
||||
Date.parse(recorded_date)
|
||||
end
|
||||
end
|
||||
|
||||
def academic_year
|
||||
@academic_year ||= AcademicYear.find_by_date response_date
|
||||
@academic_year ||= AcademicYear.find_by_date recorded_date
|
||||
end
|
||||
|
||||
def survey_item_response(survey_item:)
|
||||
|
|
|
|||
|
|
@ -102,7 +102,7 @@ RSpec.describe Cleaner do
|
|||
filename = Cleaner.new(input_filepath:, output_filepath:, log_filepath:).filename(
|
||||
headers: standard_survey_items, data:
|
||||
)
|
||||
expect(filename).to eq 'District1.standard.2022-23.csv'
|
||||
expect(filename).to eq 'district1.standard.2022-23.csv'
|
||||
end
|
||||
|
||||
context 'when the file is based on short form survey items' do
|
||||
|
|
@ -114,7 +114,7 @@ RSpec.describe Cleaner do
|
|||
filename = Cleaner.new(input_filepath:, output_filepath:, log_filepath:).filename(
|
||||
headers: short_form_survey_items, data:
|
||||
)
|
||||
expect(filename).to eq 'District1.short_form.2022-23.csv'
|
||||
expect(filename).to eq 'district1.short_form.2022-23.csv'
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -127,7 +127,7 @@ RSpec.describe Cleaner do
|
|||
filename = Cleaner.new(input_filepath:, output_filepath:, log_filepath:).filename(
|
||||
headers: early_education_survey_items, data:
|
||||
)
|
||||
expect(filename).to eq 'District1.early_education.2022-23.csv'
|
||||
expect(filename).to eq 'district1.early_education.2022-23.csv'
|
||||
end
|
||||
end
|
||||
context 'when the file is based on teacher survey items' do
|
||||
|
|
@ -139,7 +139,7 @@ RSpec.describe Cleaner do
|
|||
filename = Cleaner.new(input_filepath:, output_filepath:, log_filepath:).filename(
|
||||
headers: teacher_survey_items, data:
|
||||
)
|
||||
expect(filename).to eq 'District1.teacher.2022-23.csv'
|
||||
expect(filename).to eq 'district1.teacher.2022-23.csv'
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -153,7 +153,7 @@ RSpec.describe Cleaner do
|
|||
filename = Cleaner.new(input_filepath:, output_filepath:, log_filepath:).filename(
|
||||
headers: teacher_survey_items, data:
|
||||
)
|
||||
expect(filename).to eq 'District1.District2.teacher.2022-23.csv'
|
||||
expect(filename).to eq 'district1.district2.teacher.2022-23.csv'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -80,11 +80,17 @@ RSpec.describe SurveyItemValues, type: :model do
|
|||
end
|
||||
(survey_item_ids << common_headers).flatten
|
||||
end
|
||||
context '.response_date' do
|
||||
|
||||
context '.recorded_date' do
|
||||
it 'returns the recorded date' do
|
||||
row = { 'RecordedDate' => '2017-01-01' }
|
||||
values = SurveyItemValues.new(row:, headers:, genders:, survey_items:, schools:)
|
||||
expect(values.response_date).to eq Date.parse('2017-01-01')
|
||||
expect(values.recorded_date).to eq Date.parse('2017-01-01')
|
||||
|
||||
headers = ['Recorded Date']
|
||||
row = { 'Recorded Date' => '2017-01-02' }
|
||||
values = SurveyItemValues.new(row:, headers:, genders:, survey_items:, schools:)
|
||||
expect(values.recorded_date).to eq Date.parse('2017-01-02')
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue