Skip to content

Commit f299d57

Browse files
committed
Fix issues count in the secondary nav under Programmes
The import issues counter in the secondary nav was double counting import issues where both the vaccination record and the patient have pending changes. Because the import issues controller is doing this correctly, there was also a discrepancy between the count and what the user saw when they navigated to the import issues list.
1 parent 69d0ed2 commit f299d57

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

app/components/app_programme_navigation_component.rb

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,19 +60,22 @@ def call
6060
private
6161

6262
def import_issues_text
63-
vaccination_record_issues_count =
64-
organisation
65-
.vaccination_records
63+
vaccination_records_with_issues =
64+
helpers
65+
.policy_scope(VaccinationRecord)
6666
.where(programme:)
6767
.with_pending_changes
6868
.distinct
69-
.count
7069

71-
patient_issues_count =
72-
helpers.policy_scope(Patient).with_pending_changes.count
70+
patients_with_issues = helpers.policy_scope(Patient).with_pending_changes
71+
72+
unique_import_issues =
73+
(vaccination_records_with_issues + patients_with_issues).uniq do |record|
74+
record.is_a?(VaccinationRecord) ? record.patient : record
75+
end
7376

7477
base_text = I18n.t("import_issues.index.title")
75-
count = vaccination_record_issues_count + patient_issues_count
78+
count = unique_import_issues.count
7679

7780
safe_join([base_text, " ", render(AppCountComponent.new(count:))])
7881
end

0 commit comments

Comments
 (0)