diff --git a/app/jobs/subj_check_by_id_job.rb b/app/jobs/subj_check_by_id_job.rb new file mode 100644 index 000000000..1ed34a303 --- /dev/null +++ b/app/jobs/subj_check_by_id_job.rb @@ -0,0 +1,10 @@ +class SubjCheckByIdJob < ActiveJob::Base + queue_as :lupo_background + + def perform(event, options = {}) + subj_prefix = event[:subj_id][/(10\.\d{4,5})/, 1] + if Prefix.where(prefix: subj_prefix).exists? + Event.find_by(id: event[:id]).update_attribute(:state_event, "subj_id_error") + end + end +end diff --git a/app/jobs/subj_check_job.rb b/app/jobs/subj_check_job.rb index 24a960118..f71b790d5 100644 --- a/app/jobs/subj_check_job.rb +++ b/app/jobs/subj_check_job.rb @@ -2,11 +2,6 @@ class SubjCheckJob < ActiveJob::Base queue_as :lupo_background def perform(events, options = {}) - events.lazy.each do |event| - subj_prefix = event[:subj_id][/(10\.\d{4,5})/, 1] - if Prefix.where(prefix: subj_prefix).exists? - Event.find_by(id: event[:id]).update_attribute(:state_event, "subjId_error") - end - end + events.each { |event| SubjCheckByIdJob.perform_later(event, options) } end end