From 462cc2cd56a4b6496b9aee9750e8331bcc2a011a Mon Sep 17 00:00:00 2001 From: Ben Ubois Date: Sun, 28 Jul 2013 08:52:07 -0700 Subject: [PATCH 1/2] User workers_size instead of workers.size for better performance. --- web/views/_summary.slim | 2 +- web/views/index.slim | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/web/views/_summary.slim b/web/views/_summary.slim index ce7d1049..101a1e17 100644 --- a/web/views/_summary.slim +++ b/web/views/_summary.slim @@ -6,7 +6,7 @@ ul.unstyled.summary.row span.count #{number_with_delimiter(stats.failed)} span.desc = t('Failed') li.busy.span2 - span.count #{number_with_delimiter(workers.size)} + span.count #{number_with_delimiter(workers_size)} span.desc = t('Busy') li.scheduled.span2 span.count #{number_with_delimiter(stats.scheduled_size)} diff --git a/web/views/index.slim b/web/views/index.slim index 6f64596a..42a3d7c2 100644 --- a/web/views/index.slim +++ b/web/views/index.slim @@ -3,7 +3,7 @@ h3 = t('Workers') == slim :_workers -- if workers.size > 0 +- if workers_size > 0 .row .span2.pull-right form action="#{root_path}reset" method="post" From 09444f9f10870f93669d70f026fb2504ccefb25a Mon Sep 17 00:00:00 2001 From: Ben Ubois Date: Sun, 28 Jul 2013 09:17:33 -0700 Subject: [PATCH 2/2] Memoize workers_size. --- lib/sidekiq/web.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/sidekiq/web.rb b/lib/sidekiq/web.rb index f5da21b8..186f6345 100644 --- a/lib/sidekiq/web.rb +++ b/lib/sidekiq/web.rb @@ -46,7 +46,7 @@ module Sidekiq end def workers_size - Sidekiq.redis do |conn| + @workers_size ||= Sidekiq.redis do |conn| conn.scard('workers') end end