module Resque::Plugins::JobStats::Server

Constants

VIEW_PATH

Public Class Methods

registered(app) click to toggle source
# File lib/resque-job-stats/server.rb, line 54
def registered(app)
  app.get '/job_stats' do
    @jobs = Resque::Plugins::JobStats::Statistic.find_all(self.class.job_stats_to_display).sort
    erb(File.read(File.join(VIEW_PATH, 'job_stats.erb')))
  end
  # We have little choice in using this funky name - Resque
  # already has a "Stats" tab, and it doesn't like
  # tab names with spaces in it (it translates the url as job%20stats)
  app.tabs << "Job_Stats"

  app.get '/job_history/:job_class' do
    @job_class = Resque::Plugins::JobStats.measured_jobs.find { |j| j.to_s == params[:job_class] }
    pass unless @job_class

    @start = 0
    @start = params[:start].to_i if params[:start]
    @limit = 100
    @limit = params[:limit].to_i if params[:limit]

    @histories = @job_class.job_histories(@start,@limit)
    @size = @job_class.histories_recorded

    erb(File.read(File.join(VIEW_PATH, 'job_histories.erb')))
  end

  app.helpers(Helpers)
end

Public Instance Methods

job_stats_to_display() click to toggle source
# File lib/resque-job-stats/server.rb, line 9
def job_stats_to_display
  @job_stats_to_display ||= Resque::Plugins::JobStats::Statistic::DEFAULT_STATS
end
job_stats_to_display=(stats) click to toggle source

Set this to an array of the public accessor names in Resque::Plugins::JobStats::Statistic that you wish to display. The default is [:jobs_enqueued, :jobs_performed, :jobs_failed, :job_rolling_avg, :longest_job] Examples:

Resque::Server.job_stats_to_display = [:jobs_performed, :job_rolling_avg]
# File lib/resque-job-stats/server.rb, line 17
def job_stats_to_display=(stats)
  @job_stats_to_display = stats
end