Skip to content

Commit

Permalink
fix: make low_prio queue for caching
Browse files Browse the repository at this point in the history
  • Loading branch information
elasticspoon committed Mar 17, 2024
1 parent 2bcad5b commit 10e6605
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
2 changes: 2 additions & 0 deletions app/jobs/historical_data_cache_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@ def perform(org_id:, type:)

Rails.cache.write("#{organization.short_name}-historical-#{type}-data", HistoricalTrendService.new(organization.id, type).series)
end

def queue_name = "low_priority"
end
8 changes: 7 additions & 1 deletion config/initializers/delayed_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,13 @@
Delayed::Worker.max_attempts = 3
Delayed::Worker.max_run_time = 20.minutes
Delayed::Worker.read_ahead = 10
Delayed::Worker.default_queue_name = 'default'
Delayed::Worker.delay_jobs = !Rails.env.test?
Delayed::Worker.raise_signal_exceptions = :term
Delayed::Worker.logger = ActiveSupport::Logger.new(STDOUT)

# https://github.com/rubyforgood/human-essentials/issues/4065
Delayed::Worker.default_queue_name = 'default'
Delayed::Worker.queue_attributes = {
# bigger number is lower priority ?!?!?!?!?!
"low_priority" => { priority: 10 }
}
2 changes: 1 addition & 1 deletion spec/jobs/historical_data_cache_job_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
it "queues the job" do
expect { job }.to have_enqueued_job(described_class)
.with(org_id: organization.id, type: type)
.on_queue("default")
.on_queue("low_priority")
end

it "caches the historical data" do
Expand Down

0 comments on commit 10e6605

Please sign in to comment.