davydovanton/sidekiq-history

View on GitHub
lib/sidekiq/statistic/views/worker.erb

Summary

Maintainability
Test Coverage
<% add_to_head do %>
  <link href="<%= root_path %>common.css" media="screen" rel="stylesheet" type="text/css" />
  <link href="<%= root_path %>ui-datepicker.css" media="screen" rel="stylesheet" type="text/css" />
  <link href="<%= root_path %>sidekiq-statistic-light.css" media="screen and (prefers-color-scheme: light)" rel="stylesheet" type="text/css" />
  <link href="<%= root_path %>sidekiq-statistic-dark.css" media="screen and (prefers-color-scheme: dark)" rel="stylesheet" type="text/css" />
  <% if Sidekiq::VERSION >= '6.3' %>
    <!-- Jquery was removed in Sidekiq 6.3, so we need to explicitly add it. Several components (e.g. datepicker) require it -->
    <script src="https://code.jquery.com/jquery-3.6.0.min.js" integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4=" crossorigin="anonymous"></script>
  <% end %>
<% end %>

<script type="text/javascript" src="<%= root_path %>statistic.js"></script>

<div class='statistic'>
  <h2><%= t('WorkerInformation', worker: @name) %></h2>

  <ul class="nav nav-tabs">
    <li class="active">
      <a href="#" class="statistic__tab" data-target=".statistic__table"><%= t('InformationTable') %></a>
    </li>
  </ul>

  <div class="statistic__container live-reload">
    <div class="statistic__datepicker">
      <div>
        <label><%= t('Start') %></label>
        <input id="datepicker_from" class="statistic__datepicker__input left" autocomplete="off" />
      </div>
      <div>
        <label><%= t('End') %></label>
        <input id="datepicker_to" class="statistic__datepicker__input right" autocomplete="off" />
      </div>
    </div>

    <div class="statistic__table">
      <h2><%= t('WorkerTablePerDay') %></h2>

      <table class="statistic__table table table-hover table-bordered table-striped table-white">
        <thead>
          <th><%= t('Date') %></th>
          <th><%= t('LastRun') %></th>
          <th><%= t('Success') %></th>
          <th><%= t('Failure') %></th>
          <th><%= t('Total') %></th>
          <th><%= t('TimeSec') %></th>
          <th><%= t('AverageSec') %></th>
          <th><%= t('MinTimeSec') %></th>
          <th><%= t('MaxTimeSec') %></th>
          <th><%= t('LastJobStatus') %></th>
        </thead>
        <% @worker_statistic.each do |worker| %>
          <tr>
            <td><%= format_date worker[:date] %></td>
            <td><%= format_date worker[:runtime][:last], 'datetime' %></td>
            <td><%= worker[:success] %></td>
            <td><%= worker[:failure] %></td>
            <td><%= worker[:total] %></td>
            <td><%= worker[:runtime][:total] %></td>
            <td><%= worker[:runtime][:average] %></td>
            <td><%= worker[:runtime][:min] %></td>
            <td><%= worker[:runtime][:max] %></td>
            <td><%= worker[:last_job_status] %></td>
          </tr>
        <% end %>
      </table>
    </div>
  </div>
</div>