mattgibson/resque-scheduler-web

View on GitHub
app/views/resque_web/plugins/resque_scheduler/delayed/search.erb

Summary

Maintainability
Test Coverage
<h1>Search Results</h1>
<%= render partial: 'search_form' %>
<hr>
<% delayed = @jobs.select { |j| j['where_at'] == 'delayed' } %>
<h1>Delayed jobs</h1>
<table class="jobs table table-bordered">
  <tr>
    <th></th>
    <th></th>
    <th>Timestamp</th>
    <th>Class</th>
    <th>Args</th>
  </tr>
  <% delayed.each do |job| %>
      <tr>
        <td>
          <form action="<%= queue_now_path %>" method="post">
            <input type="hidden" name="timestamp" value="<%= job['timestamp'].to_i %>">
            <input type="submit" value="Queue now" class="btn btn-default">
          </form>
        </td>
        <td>
          <form action="<%= cancel_now_path %>" method="post">
            <input type="hidden" name="timestamp" value="<%= job['timestamp'].to_i %>">
            <input type="hidden" name="klass" value="<%= job['class'] %>">
            <input type="hidden" name="args" value="<%= Resque.encode job['args'] %>">
            <input type="submit" value="Cancel Job" class="btn btn-default">
          </form>
        </td>
        <td class='args'><%= format_time(Time.at(job['timestamp'])) %></td>
        <td class='class'><%= job['class'] %></td>
        <td class='args'><%= h job['args'].inspect %></td>
      </tr>
  <% end %>
</table>
</h1>

<% queued = @jobs.select { |j| j['where_at'] == 'queued' } %>
<h1>Queued jobs</h1>
<table class='jobs table table-bordered'>
  <tr>
    <th>Queue</th>
    <th>Class</th>
    <th>Args</th>
  </tr>
  <% queued.each do |job| %>
  <tr>
    <td class='class'><%= job['queue'] %></td>
    <td class='class'><%= job['class'] %></td>
    <td class='args'><%= h job['args'].inspect %></td>
  </tr>
  <% end %>
</table>

<% working = @jobs.select { |j| j['where_at'] == 'working' } %>
<h1>Working jobs</h1>
<table class='jobs table table-bordered'>
  <tr>
    <th>Queue</th>
    <th>Class</th>
    <th>Args</th>
  </tr>
  <% working.each do |job| %>
  <tr>
    <td class='class'><%= job['queue'] %></td>
    <td class='class'><%= job['class'] %></td>
    <td class='args'><%= h job['args'].inspect %></td>
  </tr>
  <% end %>
</table>