cctiger36/batch_manager

View on GitHub
app/views/batch_manager/batches/index.html.erb

Summary

Maintainability
Test Coverage
<div class="group title">
  <h2 style="float:left;">Batches</h2>
  <div style="float:right;text-align:right;">
    <% if resque_supported? %>
      <% if local_resque_worker? %>
        <div class="label info">Resque worker found</div>
      <% else %>
        <div class="label info">Resque worker found on <%= resque_worker_hostname %></div>
      <% end %>
    <% else %>
      <div class="label warn">Resque or Resque worker not found</div>
    <% end %>
  </div>
</div>
<table>
  <tr>
    <th>Managed?</th>
    <th>Name</th>
    <th>Ran/Limit</th>
    <th>Last run at</th>
    <th>Created at</th>
    <th>Log</th>
    <th></th>
  </tr>
  <% @details.each do |status| %>
    <% schema_batch = status.schema_batch %>
    <tr>
      <td><%= status.managed?? "Yes" : "" %></td>
      <td style="word-break:break-all;"><%= status.name %></td>
      <td style="text-align:right;"><%= schema_batch.try(:ran_times).to_i %><span class="divider">/</span><%= status.times_limit || 0 %></td>
      <td style="text-align:center;white-space:nowrap;">
        <% if last_ran_at = schema_batch.try(:last_ran_at) %>
          <%= last_ran_at.strftime('%Y-%m-%d %H:%M:%S') %>
        <% end %>
      </td>
      <td style="text-align:center;white-space:nowrap;"><%= status.created_at.strftime('%Y-%m-%d %H:%M:%S') if status.created_at %></td>
      <td style="text-align:center;white-space:nowrap;">
        <% if File.exist?(BatchManager::Logger.log_file_path(status.name)) %>
          <%= link_to "DRY", log_batch_url(escape_batch_name(status.name)), :class => "btn info" %>
          <%= link_to "X", remove_log_batch_url(escape_batch_name(status.name)), :class => "btn danger", :onclick => "return confirm('Are you sure?')" %>
        <% end %>
        <% if File.exist?(BatchManager::Logger.log_file_path(status.name, true)) %>
          <%= link_to "WET", log_batch_url(escape_batch_name(status.name), :wet => true), :class => "btn info" %>
          <%= link_to "X", remove_log_batch_url(escape_batch_name(status.name), :wet => true), :class => "btn danger", :onclick => "return confirm('Are you sure?')" %>
        <% end %>
      </td>
      <td style="text-align:center;white-space:nowrap;">
        <%= link_to "EDIT", edit_batch_url(escape_batch_name(status.name)), :class => "btn info" %>
        <% if status.managed? %>
          <%= link_to "DRY RUN", exec_batch_url(escape_batch_name(status.name)), :class => "btn info" %>
          <% if status.can_run? %>
            <%= link_to "WET RUN", exec_batch_url(escape_batch_name(status.name), :wet => true), :class => "btn danger", :onclick => "return confirm('Are you sure?')" %>
          <% else %>
            <%= link_to "WET RUN", "#", :class => "btn disabled", :onclick => "return false" %>
          <% end %>
        <% else %>
          <%= link_to "DRY RUN", "#", :class => "btn disabled", :onclick => "return false" %>
          <%= link_to "WET RUN", "#", :class => "btn disabled", :onclick => "return false" %>
        <% end %>
      </td>
    </tr>
  <% end %>
</table>