Commit f9041604 authored by Dylan Griffith's avatar Dylan Griffith

Merge branch 'tle-ruby-tally' into 'master'

Use a more succinct syntax to count by queues

See merge request gitlab-org/gitlab!49910
parents a825bc8f 25403f97
......@@ -111,7 +111,7 @@ module Gitlab
end
def self.count_by_queue(queues)
queues.each_with_object(Hash.new(0)) { |element, hash| hash[element] += 1 }
queues.tally
end
def self.proc_details(counts)
......
......@@ -123,6 +123,14 @@ RSpec.describe Gitlab::SidekiqCluster do
end
end
describe '.count_by_queue' do
it 'tallies the queue counts' do
queues = [%w(foo), %w(bar baz), %w(foo)]
expect(described_class.count_by_queue(queues)).to eq(%w(foo) => 2, %w(bar baz) => 1)
end
end
describe '.concurrency' do
using RSpec::Parameterized::TableSyntax
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment