Skip to content

Commit

Permalink
Updating display_by_last_status method (workers.rb) for better perfor…
Browse files Browse the repository at this point in the history
…mance and updating its tests
  • Loading branch information
Rhian committed Feb 15, 2021
1 parent 47ec16a commit 1323320
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions lib/sidekiq/statistic/statistic/workers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ def display
end

def display_by_last_status
filtered_workers = display.group_by {|worker| worker[:last_job_status] }
filtered_workers = display.group_by { |worker| worker[:last_job_status] }

filtered_workers['passed'] ||= []
filtered_workers['failed'] ||= []

filtered_workers.transform_keys(&:to_sym)
filtered_workers
end

def display_per_day(worker_name)
Expand Down
10 changes: 5 additions & 5 deletions test/test_sidekiq/statistic_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -112,14 +112,14 @@ module Statistic

_(subject).must_be_instance_of Hash
assert_equal subject.keys.sort,
%i[passed failed].sort
%w[passed failed].sort

_(subject[:passed]).must_be_instance_of Array
_(subject[:failed]).must_be_instance_of Array
assert_equal subject[:passed][0].keys.sort,
_(subject['passed']).must_be_instance_of Array
_(subject['failed']).must_be_instance_of Array
assert_equal subject['passed'][0].keys.sort,
%i[name last_job_status number_of_calls queue runtime].sort

assert_equal worker, subject[:passed][0][:name]
assert_equal worker, subject['passed'][0][:name]
end
end

Expand Down

0 comments on commit 1323320

Please sign in to comment.