1
0
Fork 0
mirror of https://github.com/mperham/sidekiq.git synced 2022-11-09 13:52:34 -05:00

Replace #inject/#reduce with #sum (#4325)

This commit is contained in:
fatkodima 2019-10-09 00:50:26 +03:00 committed by Mike Perham
parent ce7d1661c4
commit fc6bad64e9
3 changed files with 5 additions and 5 deletions

View file

@ -80,8 +80,8 @@ module Sidekiq
}
s = processes.size
workers_size = pipe2_res[0...s].map(&:to_i).inject(0, &:+)
enqueued = pipe2_res[s..-1].map(&:to_i).inject(0, &:+)
workers_size = pipe2_res[0...s].sum(&:to_i)
enqueued = pipe2_res[s..-1].sum(&:to_i)
default_queue_latency = if (entry = pipe1_res[6].first)
job = begin
@ -960,7 +960,7 @@ module Sidekiq
procs.each do |key|
conn.hget(key, "busy")
end
}.map(&:to_i).inject(:+)
}.sum(&:to_i)
end
end
end

View file

@ -307,7 +307,7 @@ module Sidekiq
resp[1] = resp[1].dup
resp[1][CONTENT_LENGTH] = resp[2].inject(0) { |l, p| l + p.bytesize }.to_s
resp[1][CONTENT_LENGTH] = resp[2].sum(&:bytesize).to_s
resp
end

View file

@ -95,7 +95,7 @@ describe Sidekiq::Scheduled do
assert intervals.all?{|x| x >= 5}
assert intervals.all?{|x| x <= 15}
assert_in_delta 10, intervals.reduce(&:+).to_f / i, 0.5
assert_in_delta 10, intervals.sum.to_f / i, 0.5
end
end