Module: Submission::DelayedJobBehaviour
- Included in:
- Submission
- Defined in:
- app/models/submission/delayed_job_behaviour.rb
Instance Method Summary collapse
-
#build_batch ⇒ Object
rubocop:todo Metrics/MethodLength.
- #default_priority ⇒ Object
-
#finalize_build! ⇒ Object
rubocop:enable Metrics/MethodLength.
- #queue_submission_builder ⇒ Object
Instance Method Details
#build_batch ⇒ Object
rubocop:todo Metrics/MethodLength
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'app/models/submission/delayed_job_behaviour.rb', line 13 def build_batch # rubocop:todo Metrics/AbcSize ActiveRecord::Base.transaction { finalize_build! } rescue ActiveRecord::StatementInvalid => e # If an SQL problems occurs, it's more likely that's it's # a one shot one, e.g. timeout , deadlock etc ... # So we don't want the submission to fail but the delayed job to # retry later. Therefore the DelayedJob should fail raise e rescue ActiveRecord::RecordInvalid, Submission::ProjectValidation::Error => e Rails.logger.error(e.) Rails.logger.error(e.backtrace) (e.) rescue => e Rails.logger.error(e.) Rails.logger.error(e.backtrace) ("#{e.}\n#{e.backtrace.join("\n")}") end |
#default_priority ⇒ Object
3 4 5 |
# File 'app/models/submission/delayed_job_behaviour.rb', line 3 def default_priority configatron.delayed_job.fetch(:submission_process_priority, 0) end |
#finalize_build! ⇒ Object
rubocop:enable Metrics/MethodLength
33 34 35 36 |
# File 'app/models/submission/delayed_job_behaviour.rb', line 33 def finalize_build! process! ready! end |
#queue_submission_builder ⇒ Object
7 8 9 10 |
# File 'app/models/submission/delayed_job_behaviour.rb', line 7 def queue_submission_builder # Lower priorities get processed faster. This ensures high priority submissions get processed first. Delayed::Job.enqueue SubmissionBuilderJob.new(id), priority: default_priority - priority end |