clean up formatting reports

This commit is contained in:
Sam 2016-05-31 07:57:15 +10:00
parent 6796b15857
commit e9ba6e4e99
3 changed files with 25 additions and 6 deletions

View File

@ -15,7 +15,7 @@
<th style="width: 15%">Hostname:Pid</th>
<th style="width: 15%">Live Slots delta</th>
<th style="width: 15%">Started At</th>
<th style="width: 15%">Duration (ms)</th>
<th style="width: 15%">Duration</th>
<th style="width: 15%"></th>
</thead>
<tbody>
@ -28,11 +28,13 @@
<%= stat.live_slots_finish - stat.live_slots_start %>
<% end %>
</td>
<td><%= relative_time stat.started_at %></td>
<td><%= stat.duration_ms %></td>
<td><%= sane_time stat.started_at %></td>
<td><%= sane_duration stat.duration_ms %></td>
<td>
<% if !stat.success %>
<span>FAILED</span>
<% if stat.success.nil? %>
RUNNING
<% elsif !stat.success %>
FAILED
<% end %>
</td>
</tr>

View File

@ -43,7 +43,7 @@
<%= @info.prev_result %>
</td>
<td>
<%= @info.prev_duration %>
<%= sane_duration @info.prev_duration %>
</td>
<td>
<%= @info.current_owner %>

View File

@ -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