Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Actually change smaller_number_is_higher_priority for v4 #1402

Merged
merged 1 commit into from
Jul 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions demo/config/initializers/good_job.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
Rails.application.configure do
# TODO: Remove on GoodJob 4.0 release
config.good_job.smaller_number_is_higher_priority = true

config.good_job.cron = {
example: {
cron: '*/5 * * * * *', # every 5 seconds
Expand Down
6 changes: 5 additions & 1 deletion lib/good_job/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ class Configuration
DEFAULT_DASHBOARD_LIVE_POLL_ENABLED = true
# Default enqueue_after_transaction_commit
DEFAULT_ENQUEUE_AFTER_TRANSACTION_COMMIT = false
# Default smaller_number_is_higher_priority
DEFAULT_SMALLER_NUMBER_IS_HIGHER_PRIORITY = true

def self.validate_execution_mode(execution_mode)
raise ArgumentError, "GoodJob execution mode must be one of #{EXECUTION_MODES.join(', ')}. It was '#{execution_mode}' which is not valid." unless execution_mode.in?(EXECUTION_MODES)
Expand Down Expand Up @@ -378,7 +380,9 @@ def enable_listen_notify
end

def smaller_number_is_higher_priority
rails_config[:smaller_number_is_higher_priority]
return rails_config[:smaller_number_is_higher_priority] unless rails_config[:smaller_number_is_higher_priority].nil?

DEFAULT_SMALLER_NUMBER_IS_HIGHER_PRIORITY
end

def dashboard_default_locale
Expand Down
6 changes: 3 additions & 3 deletions spec/app/models/good_job/job_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -579,14 +579,14 @@ def job_params
expect(described_class.priority_ordered.pluck(:priority)).to eq([-50, 50])
end

it 'smaller_number_is_higher_priority=false orders with smaller priority being LOWER priority' do
it 'smaller_number_is_higher_priority=false orders with smaller number being LOWER priority' do
allow(Rails.application.config).to receive(:good_job).and_return({ smaller_number_is_higher_priority: false })
expect(described_class.priority_ordered.pluck(:priority)).to eq([50, -50])
end

it 'smaller_number_is_higher_priority=false orders with lower priority being LOWER priority' do
it 'smaller_number_is_higher_priority=nil orders with smaller number being HIGHER priority' do
allow(Rails.application.config).to receive(:good_job).and_return({})
expect(described_class.priority_ordered.pluck(:priority)).to eq([50, -50])
expect(described_class.priority_ordered.pluck(:priority)).to eq([-50, 50])
end
end

Expand Down