mirror of
https://github.com/mperham/sidekiq.git
synced 2022-11-09 13:52:34 -05:00
Update Dashboard summary stats with real-time graph update.
This commit is contained in:
parent
65e1a7edd8
commit
b6714cdc1c
4 changed files with 36 additions and 7 deletions
|
@ -214,7 +214,13 @@ module Sidekiq
|
|||
get '/dashboard/stats' do
|
||||
stats = Sidekiq::Stats.new
|
||||
content_type :json
|
||||
Sidekiq.dump_json({ processed: stats.processed, failed: stats.failed })
|
||||
Sidekiq.dump_json({
|
||||
processed: stats.processed,
|
||||
failed: stats.failed,
|
||||
enqueued: stats.enqueued,
|
||||
scheduled: Sidekiq::ScheduledSet.new.size,
|
||||
retries: Sidekiq::RetrySet.new.size
|
||||
})
|
||||
end
|
||||
|
||||
def self.tabs
|
||||
|
|
|
@ -205,9 +205,12 @@ class TestWeb < MiniTest::Unit::TestCase
|
|||
conn.set("stat:processed", 5)
|
||||
conn.set("stat:failed", 2)
|
||||
end
|
||||
2.times { add_retry }
|
||||
3.times { add_scheduled }
|
||||
|
||||
get '/dashboard/stats'
|
||||
assert_equal 200, last_response.status
|
||||
assert_equal "{\"processed\":5,\"failed\":2}", last_response.body
|
||||
assert_equal "{\"processed\":5,\"failed\":2,\"enqueued\":0,\"scheduled\":3,\"retries\":2}", last_response.body
|
||||
end
|
||||
|
||||
def add_scheduled
|
||||
|
|
|
@ -52,6 +52,8 @@ var realtimeGraph = function(updatePath) {
|
|||
|
||||
Sidekiq.processed = data.processed;
|
||||
Sidekiq.failed = data.failed;
|
||||
|
||||
updateStatsSummary(data);
|
||||
});
|
||||
i++;
|
||||
}, timeInterval);
|
||||
|
@ -104,6 +106,24 @@ var createSeries = function(obj) {
|
|||
return series;
|
||||
};
|
||||
|
||||
var updateStatsSummary = function(data) {
|
||||
$('ul.summary li.processed span.count').html(data.processed.numberWithDelimiter())
|
||||
$('ul.summary li.failed span.count').html(data.failed.numberWithDelimiter())
|
||||
$('ul.summary li.scheduled span.count').html(data.scheduled.numberWithDelimiter())
|
||||
$('ul.summary li.retries span.count').html(data.retries.numberWithDelimiter())
|
||||
$('ul.summary li.enqueued span.count').html(data.enqueued.numberWithDelimiter())
|
||||
}
|
||||
|
||||
Number.prototype.numberWithDelimiter = function(delimiter) {
|
||||
var number = this + '', delimiter = delimiter || ',';
|
||||
var split = number.split('.');
|
||||
split[0] = split[0].replace(
|
||||
/(\d)(?=(\d\d\d)+(?!\d))/g,
|
||||
'$1' + delimiter
|
||||
);
|
||||
return split.join('.');
|
||||
};
|
||||
|
||||
$(function(){
|
||||
realtimeGraph();
|
||||
historyGraph();
|
||||
|
|
|
@ -1,19 +1,19 @@
|
|||
ul.unstyled.summary
|
||||
li
|
||||
li.processed
|
||||
span.count #{number_with_delimiter(stats.processed)}
|
||||
span.desc Processed
|
||||
li
|
||||
li.failed
|
||||
span.count #{number_with_delimiter(stats.failed)}
|
||||
span.desc Failed
|
||||
li
|
||||
span.count #{number_with_delimiter(workers.size)}
|
||||
span.desc Busy
|
||||
li
|
||||
li.scheduled
|
||||
span.count #{number_with_delimiter(scheduled_job_count)}
|
||||
span.desc Scheduled
|
||||
li
|
||||
li.retries
|
||||
span.count #{number_with_delimiter(retry_job_count)}
|
||||
span.desc Retries
|
||||
li
|
||||
li.enqueued
|
||||
span.count #{number_with_delimiter(stats.enqueued)}
|
||||
span.desc Enqueued
|
||||
|
|
Loading…
Reference in a new issue