Skip to content

Commit 21552dc

Browse files
committed
Don't review changesets waiting to be processed
MAV-2604 Add tests for MAV-2604
1 parent 32ff9a4 commit 21552dc

2 files changed

Lines changed: 10 additions & 2 deletions

File tree

app/jobs/review_patient_changeset_job.rb

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ def perform(patient_changeset_id)
1717

1818
import = patient_changeset.import
1919

20-
unless import.changesets.calculating_review.any? ||
21-
import.changesets.import_invalid.any?
20+
if all_jobs_finished_and_import_valid(import)
2221
if import.is_a?(ClassImport)
2322
ReviewClassImportSchoolMoveJob.perform_later(import.id)
2423
elsif import.calculating_re_review?
@@ -28,4 +27,11 @@ def perform(patient_changeset_id)
2827
end
2928
end
3029
end
30+
31+
private
32+
33+
def all_jobs_finished_and_import_valid(import)
34+
import.changesets.still_processing.none? &&
35+
import.changesets.import_invalid.none?
36+
end
3137
end

app/models/patient_changeset.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,8 @@ class PatientChangeset < ApplicationRecord
116116
).where.not(status: :processed)
117117
end
118118

119+
scope :still_processing, -> { where(status: %i[pending calculating_review]) }
120+
119121
def self.from_import_row(row:, import:, row_number:)
120122
create!(
121123
import:,

0 commit comments

Comments
 (0)