From 0877d115226692b67312785dd1048e70ba62cda8 Mon Sep 17 00:00:00 2001 From: Kat Date: Mon, 11 Sep 2023 14:08:14 +0100 Subject: [PATCH] refactor --- app/services/imports/import_report_service.rb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app/services/imports/import_report_service.rb b/app/services/imports/import_report_service.rb index 10c4fec7e..e636bee90 100644 --- a/app/services/imports/import_report_service.rb +++ b/app/services/imports/import_report_service.rb @@ -92,14 +92,14 @@ module Imports LettingsLog.where.not(old_id: nil).where(status: "in_progress").each do |lettings_log| applicable_questions = lettings_log.form.subsections.map { |s| s.applicable_questions(lettings_log).select { |q| q.enabled?(lettings_log) } }.flatten - unanswered_questions = applicable_questions.filter { |q| q.unanswered?(lettings_log) }.map(&:id) - lettings_log.optional_fields + unanswered_questions = (applicable_questions.filter { |q| q.unanswered?(lettings_log) }.map(&:id) - lettings_log.optional_fields).join(", ") - if unanswered_question_counts[unanswered_questions.join(", ")].present? - unanswered_question_counts[unanswered_questions.join(", ")] += 1 - missing_answers_example_sets[unanswered_questions.join(", ")] << { id: lettings_log.id, old_id: lettings_log.old_id, owning_organisation_id: lettings_log.owning_organisation_id } unless unanswered_question_counts[unanswered_questions.join(", ")] > 10 + if unanswered_question_counts[unanswered_questions].present? + 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 else - unanswered_question_counts[unanswered_questions.join(", ")] = 1 - missing_answers_example_sets[unanswered_questions.join(", ")] = [{ id: lettings_log.id, old_id: lettings_log.old_id, owning_organisation_id: lettings_log.owning_organisation_id }] + 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 }] end end