Browse Source

Report old form id instead of old id

pull/1892/head
Kat 3 years ago
parent
commit
96137af663
  1. 8
      app/services/imports/import_report_service.rb
  2. 32
      spec/fixtures/files/imported_lettings_logs_missing_answers_examples.csv
  3. 8
      spec/services/imports/import_report_service_spec.rb

8
app/services/imports/import_report_service.rb

@ -96,10 +96,10 @@ module Imports
if unanswered_question_counts[unanswered_questions].present? if unanswered_question_counts[unanswered_questions].present?
unanswered_question_counts[unanswered_questions] += 1 unanswered_question_counts[unanswered_questions] += 1
missing_answers_example_sets[unanswered_questions] << { id: lettings_log.id, old_id: lettings_log.old_id, owning_organisation_id: lettings_log.owning_organisation_id } unless unanswered_question_counts[unanswered_questions] > 10 missing_answers_example_sets[unanswered_questions] << { id: lettings_log.id, old_form_id: lettings_log.old_form_id, owning_organisation_id: lettings_log.owning_organisation_id } unless unanswered_question_counts[unanswered_questions] > 10
else else
unanswered_question_counts[unanswered_questions] = 1 unanswered_question_counts[unanswered_questions] = 1
missing_answers_example_sets[unanswered_questions] = [{ id: lettings_log.id, old_id: lettings_log.old_id, owning_organisation_id: lettings_log.owning_organisation_id }] missing_answers_example_sets[unanswered_questions] = [{ id: lettings_log.id, old_form_id: lettings_log.old_form_id, owning_organisation_id: lettings_log.owning_organisation_id }]
end end
end end
@ -113,12 +113,12 @@ module Imports
end end
missing_answers_examples = CSV.generate do |report| missing_answers_examples = CSV.generate do |report|
headers = ["Missing answers", "Organisation ID", "Log ID", "Old Log ID"] headers = ["Missing answers", "Organisation ID", "Log ID", "Old Form ID"]
report << headers report << headers
missing_answers_example_sets.each do |missing_answers, examples| missing_answers_example_sets.each do |missing_answers, examples|
examples.each do |example| examples.each do |example|
report << [missing_answers, example[:owning_organisation_id], example[:id], example[:old_id]] report << [missing_answers, example[:owning_organisation_id], example[:id], example[:old_form_id]]
end end
end end
end end

32
spec/fixtures/files/imported_lettings_logs_missing_answers_examples.csv vendored

@ -1,16 +1,16 @@
Missing answers,Organisation ID,Log ID,Old Log ID Missing answers,Organisation ID,Log ID,Old Form ID
age1_known,{org_id0},{id0},age1_known_0 age1_known,{org_id0},{id0},1000
age1_known,{org_id1},{id1},age1_known_1 age1_known,{org_id1},{id1},1001
age1_known,{org_id2},{id2},age1_known_2 age1_known,{org_id2},{id2},1002
age1_known,{org_id3},{id3},age1_known_3 age1_known,{org_id3},{id3},1003
age1_known,{org_id4},{id4},age1_known_4 age1_known,{org_id4},{id4},1004
age1_known,{org_id5},{id5},age1_known_5 age1_known,{org_id5},{id5},1005
age1_known,{org_id6},{id6},age1_known_6 age1_known,{org_id6},{id6},1006
age1_known,{org_id7},{id7},age1_known_7 age1_known,{org_id7},{id7},1007
age1_known,{org_id8},{id8},age1_known_8 age1_known,{org_id8},{id8},1008
age1_known,{org_id9},{id9},age1_known_9 age1_known,{org_id9},{id9},1009
beds,{org_id2_0},{id2_0},beds_0 beds,{org_id2_0},{id2_0},2000
beds,{org_id2_1},{id2_1},beds_1 beds,{org_id2_1},{id2_1},2001
beds,{org_id2_2},{id2_2},beds_2 beds,{org_id2_2},{id2_2},2002
beds,{org_id2_3},{id2_3},beds_3 beds,{org_id2_3},{id2_3},2003
"beds, age1_known",{org_id},{id},beds_and_age "beds, age1_known",{org_id},{id},300

1 Missing answers Organisation ID Log ID Old Log ID Old Form ID
2 age1_known {org_id0} {id0} age1_known_0 1000
3 age1_known {org_id1} {id1} age1_known_1 1001
4 age1_known {org_id2} {id2} age1_known_2 1002
5 age1_known {org_id3} {id3} age1_known_3 1003
6 age1_known {org_id4} {id4} age1_known_4 1004
7 age1_known {org_id5} {id5} age1_known_5 1005
8 age1_known {org_id6} {id6} age1_known_6 1006
9 age1_known {org_id7} {id7} age1_known_7 1007
10 age1_known {org_id8} {id8} age1_known_8 1008
11 age1_known {org_id9} {id9} age1_known_9 1009
12 beds {org_id2_0} {id2_0} beds_0 2000
13 beds {org_id2_1} {id2_1} beds_1 2001
14 beds {org_id2_2} {id2_2} beds_2 2002
15 beds {org_id2_3} {id2_3} beds_3 2003
16 beds, age1_known {org_id} {id} beds_and_age 300

8
spec/services/imports/import_report_service_spec.rb

@ -107,18 +107,20 @@ RSpec.describe Imports::ImportReportService do
before do before do
create_list(:lettings_log, 11, :completed, age1_known: nil) do |log, i| create_list(:lettings_log, 11, :completed, age1_known: nil) do |log, i|
log.old_id = "age1_known_#{i}" log.old_form_id = "100#{i}"
log.old_id = "old_id_age1_known_#{i}"
log.save! log.save!
expected__answers_examples_content.sub!("{id#{i}}", log.id.to_s) expected__answers_examples_content.sub!("{id#{i}}", log.id.to_s)
expected__answers_examples_content.sub!("{org_id#{i}}", log.owning_organisation_id.to_s) expected__answers_examples_content.sub!("{org_id#{i}}", log.owning_organisation_id.to_s)
end end
create_list(:lettings_log, 4, :completed, beds: nil) do |log, i| create_list(:lettings_log, 4, :completed, beds: nil) do |log, i|
log.old_id = "beds_#{i}" log.old_form_id = "200#{i}"
log.old_id = "old_id_beds_#{i}"
expected__answers_examples_content.sub!("{id2_#{i}}", log.id.to_s) expected__answers_examples_content.sub!("{id2_#{i}}", log.id.to_s)
expected__answers_examples_content.sub!("{org_id2_#{i}}", log.owning_organisation_id.to_s) expected__answers_examples_content.sub!("{org_id2_#{i}}", log.owning_organisation_id.to_s)
log.save! log.save!
end end
create(:lettings_log, :completed, age1_known: nil, beds: nil, old_id: "beds_and_age") do |log| create(:lettings_log, :completed, age1_known: nil, beds: nil, old_form_id: "300", old_id: "123") do |log|
expected__answers_examples_content.sub!("{id}", log.id.to_s) expected__answers_examples_content.sub!("{id}", log.id.to_s)
expected__answers_examples_content.sub!("{org_id}", log.owning_organisation_id.to_s) expected__answers_examples_content.sub!("{org_id}", log.owning_organisation_id.to_s)
end end

Loading…
Cancel
Save