.row.tbl-header .col-xs-12 %h4 %a{href: url_for('/nodes')} nodes \/ stats .row .pull-right %button.ColVis_Button{type: 'button', onclick: 'history.go();'} %span.glyphicon.glyphicon-repeat Refresh .table-responsive %table.table.table-condensed.table-striped.table-hover#statsTable %caption %span Node Statistics %thead %tr %th Name %th Total Runs %th Total Failures %th Failure Rate %th Average Run Time %th Last Status %th Last Update %th Last Failure %tbody - @data.map do |node, stats| - status = 'no_connection' - successes = stats.successes - failures = stats.failures - avg_success_time = 0 - avg_failure_time = 0 - avg_time = 0 - row_class = '' - if success = stats.get(:success) - last_success = success.last[:end] - avg_success_time = success.collect {|x| x[:time]} - avg_success_time = avg_success_time.inject {|sum, x| sum + x} - avg_success_time /= successes - if no_connection = stats.get(:no_connection) - last_failure = no_connection.last[:end] - avg_failure_time = no_connection.collect {|x| x[:time]} - avg_failure_time = avg_failure_time.inject {|sum, x| sum + x} - avg_failure_time /= failures - if avg_success_time > 0 && avg_failure_time > 0 - avg_time = (avg_success_time + avg_failure_time) / 2 - elsif avg_success_time > 0 - avg_time = avg_success_time - elsif avg_failure_time > 0 - avg_time = avg_failure_time - avg_time = "#{'%.2f' % avg_time}" unless avg_time == 'Unknown' - if last_success && last_failure - status = last_success > last_failure ? 'success' : 'no_connection' - elsif last_success - status = 'success' - last_failure = 'never' - else - last_success = 'never' - total_runs = successes + failures - failure_rate = (failures / total_runs.to_f) * 100 - row_class = 'warning' if failure_rate >= 50 - row_class = 'danger' if failure_rate >= 75 %tr{class: row_class} %td= node %td= total_runs %td= failures %td #{'%.2f' % failure_rate}% %td #{'%.2f' % avg_time} %td %div{title: status, class: status} %td.time= last_success %td.time= last_failure :javascript $(function() { $('#statsTable').dataTable({ dom: 'C<"clear">lfrtip', "lengthMenu": [[50, 250, 500, -1], [50, 250, 500, "All"]], bAutoWidth: false, columnDefs: [{ visible: false, targets: 1 }, { render: function ( data, type, row) { return type === 'display' ? data + 's' : data }, targets: 4 }], colVis: { exclude: [0, 5] } }); });