Module: Resque::Plugins::JobStats::Server

Defined in:
lib/resque-job-stats/server.rb

Defined Under Namespace

Modules: Helpers

Constant Summary collapse

VIEW_PATH =
File.join(File.dirname(__FILE__), 'server', 'views')

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.registered(app) ⇒ Object



54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# 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

Instance Method Details

#job_stats_to_displayObject



9
10
11
# 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) ⇒ Object

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]


17
18
19
# File 'lib/resque-job-stats/server.rb', line 17

def job_stats_to_display=(stats)
  @job_stats_to_display = stats
end