Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Allow jobs to define to store status even without a reference

Oliver Günther7612e3496495
diff --git a/app/workers/application_job.rb b/app/workers/application_job.rb
index 66536d1b49c..81f1d93db31 100644
--- a/app/workers/application_job.rb
+++ b/app/workers/application_job.rb
@@ -29,6 +29,7 @@
require 'active_job'
class ApplicationJob < ::ActiveJob::Base
+
around_perform do |_job, block|
reload_mailer_configuration!
with_clean_request_store { block.call }
@@ -87,8 +88,14 @@ class ApplicationJob < ::ActiveJob::Base
# Delayed jobs can have a status:
# Delayed::Job::Status
# which is related to the job via a reference which is an AR model instance.
- # If no such reference is defined, there is no status stored in the db.
def status_reference
nil
end
+
+ ##
+ # Determine whether to store a status object for this job
+ # By default, will only store if status_reference is present
+ def store_status?
+ !status_reference.nil?
+ end
end