Skip to content

Commit

Permalink
fix: rename threshold methods
Browse files Browse the repository at this point in the history
  • Loading branch information
deniskorobicyn committed Aug 24, 2016
1 parent b96cc7c commit dfaf158
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
8 changes: 4 additions & 4 deletions app/controllers/resque/queues/status_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ def show
age(params['queue'])
when 'size'
size(params['queue'])
when 'size_threshold'
Resque.queues_info.size_threshold(params.fetch('queue'))
when 'age_threshold'
Resque.queues_info.age_threshold(params.fetch('queue'))
when 'threshold_size'
Resque.queues_info.threshold_size(params.fetch('queue'))
when 'threshold_age'
Resque.queues_info.threshold_age(params.fetch('queue'))
else
0
end.to_s
Expand Down
8 changes: 4 additions & 4 deletions lib/resque/integration/queues_info.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def age_overall

return 0 if job.nil? || max_time.nil?

max_time >= age_threshold(job['queue']) ? max_time : 0
max_time >= threshold_age(job['queue']) ? max_time : 0
end

def size_for_queue(queue = nil)
Expand All @@ -32,14 +32,14 @@ def size_overall
[queue, Resque.size(queue).to_i]
end.max_by(&:last)

size >= size_threshold(queue) ? size : 0
size >= threshold_size(queue) ? size : 0
end

def size_threshold(queue)
def threshold_size(queue)
(@queues[queue] || @defaults)['max_size']
end

def age_threshold(queue)
def threshold_age(queue)
(@queues[queue] || @defaults)['max_age']
end

Expand Down
8 changes: 4 additions & 4 deletions spec/resque/integration/queues_info_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -189,15 +189,15 @@
let(:queue_name) { 'first' }

it 'returns threshold for age' do
expect(queue_info.age_threshold(queue_name)).to eq 20
expect(queue_info.threshold_age(queue_name)).to eq 20
end
end

context 'when queue not defined in config' do
let(:queue_name) { 'second' }

it 'returns default threshold' do
expect(queue_info.age_threshold(queue_name)).to eq 10
expect(queue_info.threshold_age(queue_name)).to eq 10
end
end
end
Expand All @@ -207,15 +207,15 @@
let(:queue_name) { 'first' }

it 'returns threshold for size' do
expect(queue_info.size_threshold(queue_name)).to eq 100
expect(queue_info.threshold_size(queue_name)).to eq 100
end
end

context 'when queue not defined in config' do
let(:queue_name) { 'second' }

it 'returns default threshold' do
expect(queue_info.size_threshold(queue_name)).to eq 10
expect(queue_info.threshold_size(queue_name)).to eq 10
end
end
end
Expand Down

0 comments on commit dfaf158

Please sign in to comment.