From e9ba6e4e99cdec212b92203ab6ce89db9745de52 Mon Sep 17 00:00:00 2001 From: Sam Date: Tue, 31 May 2016 07:57:15 +1000 Subject: [PATCH] clean up formatting reports --- lib/scheduler/views/history.erb | 12 +++++++----- lib/scheduler/views/scheduler.erb | 2 +- lib/scheduler/web.rb | 17 +++++++++++++++++ 3 files changed, 25 insertions(+), 6 deletions(-) diff --git a/lib/scheduler/views/history.erb b/lib/scheduler/views/history.erb index f6c8f5c92fc..c1cc026ba71 100644 --- a/lib/scheduler/views/history.erb +++ b/lib/scheduler/views/history.erb @@ -15,7 +15,7 @@ Hostname:Pid Live Slots delta Started At - Duration (ms) + Duration @@ -28,11 +28,13 @@ <%= stat.live_slots_finish - stat.live_slots_start %> <% end %> - <%= relative_time stat.started_at %> - <%= stat.duration_ms %> + <%= sane_time stat.started_at %> + <%= sane_duration stat.duration_ms %> - <% if !stat.success %> - FAILED + <% if stat.success.nil? %> + RUNNING + <% elsif !stat.success %> + FAILED <% end %> diff --git a/lib/scheduler/views/scheduler.erb b/lib/scheduler/views/scheduler.erb index d50aaa861ea..85fb6da8d97 100644 --- a/lib/scheduler/views/scheduler.erb +++ b/lib/scheduler/views/scheduler.erb @@ -43,7 +43,7 @@ <%= @info.prev_result %> - <%= @info.prev_duration %> + <%= sane_duration @info.prev_duration %> <%= @info.current_owner %> diff --git a/lib/scheduler/web.rb b/lib/scheduler/web.rb index d3af236433f..6d414ce8e91 100644 --- a/lib/scheduler/web.rb +++ b/lib/scheduler/web.rb @@ -4,6 +4,23 @@ module Scheduler VIEWS = File.expand_path('views', File.dirname(__FILE__)) unless defined? VIEWS def self.registered(app) + + app.helpers do + def sane_time(time) + return unless time + time + end + + def sane_duration(duration) + return unless duration + if duration < 1000 + "#{duration}ms" + elsif duration < 60*1000 + "#{'%.2f' % (duration/1000.0)} secs" + end + end + end + app.get "/scheduler" do RailsMultisite::ConnectionManagement.with_connection("default") do @manager = Scheduler::Manager.without_runner