Use ActiveJob instead of Resque directly

This allows us to directly pass entities to the job.
This commit is contained in:
Patrick Gansterer 2020-07-31 14:09:45 +02:00
parent 07c8393c8c
commit 47d9c79617
16 changed files with 76 additions and 73 deletions

View file

@ -47,6 +47,9 @@ module Foodsoft
# TODO Disable this. Uncommenting this line will currently cause rspec to fail.
config.action_controller.permit_all_parameters = true
config.active_job.queue_adapter = :resque
config.active_job.queue_name_prefix = ENV.fetch('JOB_QUEUE_PREFIX', "foodsoft_#{Rails.env}")
# Enable the asset pipeline
config.assets.enabled = true

View file

@ -60,10 +60,6 @@ Rails.application.configure do
# Use a different cache store in production.
# config.cache_store = :mem_cache_store
# Use a real queuing backend for Active Job (and separate queues per environment)
config.active_job.queue_adapter = :resque
config.active_job.queue_name_prefix = "foodsoft_#{Rails.env}"
config.action_mailer.perform_caching = false
# Ignore bad email addresses and do not raise email delivery errors.

View file

@ -0,0 +1,22 @@
module FoodsoftActiveJobArguments
def self.included(base) # :nodoc:
base.class_eval do
alias_method :orig_deserialize, :deserialize
alias_method :orig_serialize, :serialize
def serialize(arguments)
ret = orig_serialize(arguments)
ret.unshift FoodsoftConfig.scope
end
def deserialize(arguments)
FoodsoftConfig.select_multifoodcoop arguments.shift
orig_deserialize(arguments)
end
end
end
end
ActiveSupport.on_load(:after_initialize) do
ActiveJob::Arguments.include FoodsoftActiveJobArguments
end