lib/sidekiq/web/helpers.rb in sidekiq-6.1.3 vs lib/sidekiq/web/helpers.rb in sidekiq-6.2.0

- old
+ new

@@ -20,10 +20,18 @@ end end end end + def singularize(str, count) + if count == 1 && str.respond_to?(:singularize) # rails + str.singularize + else + str + end + end + def clear_caches @strings = nil @locale_files = nil @available_locales = nil end @@ -156,12 +164,11 @@ @stats ||= Sidekiq::Stats.new end def redis_connection Sidekiq.redis do |conn| - c = conn.connection - "redis://#{c[:location]}/#{c[:db]}" + conn.connection[:id] end end def namespace @ns ||= Sidekiq.redis { |conn| conn.respond_to?(:namespace) ? conn.namespace : nil } @@ -257,15 +264,17 @@ end end end def format_memory(rss_kb) - return "" if rss_kb.nil? || rss_kb == 0 + return "0" if rss_kb.nil? || rss_kb == 0 if rss_kb < 100_000 "#{number_with_delimiter(rss_kb)} KB" - else + elsif rss_kb < 10_000_000 "#{number_with_delimiter((rss_kb / 1024.0).to_i)} MB" + else + "#{number_with_delimiter((rss_kb / (1024.0 * 1024.0)).round(1))} GB" end end def number_with_delimiter(number) return "" if number.nil?