Skip to content

Commit

Permalink
separate active job
Browse files Browse the repository at this point in the history
  • Loading branch information
kjgarza committed Feb 14, 2020
1 parent 339fcef commit 1fe9b88
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
10 changes: 10 additions & 0 deletions app/jobs/subj_check_by_id_job.rb
Original file line number Diff line number Diff line change
@@ -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
7 changes: 1 addition & 6 deletions app/jobs/subj_check_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 1fe9b88

Please sign in to comment.