Sha256: 8bcfcb41b0e3c2285fa41ec5dc9dbffe50f1824488694ff252444ee2effa8e33

Contents?: true

Size: 1.49 KB

Versions: 3

Compression:

Stored size: 1.49 KB

Contents

ResqueAdmin::Server.helpers do
  ####################
  #failed.erb helpers#
  ####################

  def failed_date_format
    "%Y/%m/%d %T %z"
  end

  def failed_multiple_queues?
    return @multiple_failed_queues if defined?(@multiple_failed_queues)
    @multiple_failed_queues = ResqueAdmin::Failure.queues.size > 1
  end

  def failed_size
    @failed_size ||= ResqueAdmin::Failure.count(params[:queue], params[:class])
  end

  def failed_per_page
    @failed_per_page = if params[:class]
      failed_size
    else
      20
    end
  end

  def failed_start_at
    params[:start].to_i
  end

  def failed_end_at
    if failed_start_at + failed_per_page > failed_size
      failed_size
    else
      failed_start_at  + failed_per_page - 1
    end
  end

  def failed_order
    params[:order] || 'desc'
  end

  def failed_class_counts(queue = params[:queue])
    classes = Hash.new(0)
    ResqueAdmin::Failure.each(0, ResqueAdmin::Failure.count(queue), queue) do |_, item|
      class_name = item['payload']['class'] if item['payload']
      class_name ||= "nil"
      classes[class_name] += 1
    end
    classes
  end

  def page_entries_info(start, stop, size, name = nil)
    if size == 0
      name ? "No #{name}s" : '<b>0</b>'
    elsif size == 1
      'Showing <b>1</b>' + (name ? " #{name}" : '')
    elsif size > failed_per_page
      "Showing #{start}-#{stop} of <b>#{size}</b>" + (name ? " #{name}s" : '')
    else
      "Showing #{start} to <b>#{size - 1}</b>" + (name ? " #{name}s" : '')
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
resque_admin-1.0.5 lib/resque_admin/server/helpers.rb
resque_admin-0.2.0 lib/resque_admin/server/helpers.rb
resque_admin-2.4.4 lib/resque_admin/server/helpers.rb