brynary/rack-bug

View on GitHub
lib/rack/bug/views/panels/cache.html.erb

Summary

Maintainability
Test Coverage
<h3>Cache Usage</h3>
<table id="cache_usage">
  <colgroup>
    <col width="12%"/>
    <col width="12%"/>
    <col width="12%"/>
    <col width="12%"/>
    <col width="12%"/>
    <col width="12%"/>
    <col width="12%"/>
    <col width="12%"/>
  </colgroup>
  <tr>
    <th>Total Calls</th>
    <td><%= stats.calls %></td>
    
    <th>Total Time</th>
    <td><%= stats.display_time %></td>
    
    <th>Hits</th>
    <td><%= stats.hits %></td>
    
    <th>Misses</th>
    <td><%= stats.misses %></td>
  </tr>
  <tr>
    <th>gets</th>
    <td><%= stats.gets %></td>
    
    <th>sets</th>
    <td><%= stats.sets %></td>
    
    <th>deletes</th>
    <td><%= stats.deletes %></td>
    
    <th>get_multis</th>
    <td><%= stats.get_multis %></td>
  </tr>
</table>

<% if stats.queries.any? %>
  <h3>Breakdown</h3>
  <table id="cache_breakdown" class="sortable">
    <thead>
      <tr>
        <th>Time&nbsp;(ms)</th>
        <th>Type</th>
        <th>Parameters</th>
        <th>Function</th>
        <th>
          <a href="/__rack_bug__/delete_cache_list?<%= signed_params(stats.queries_to_param) %>" class="rb_delete_cache">
            Delete All
          </a>
        </th>
      </tr>
    </thead>
    <tbody>
      <% i = 1 %>
      <% stats.queries.each do |query| %>
        <tr>
          <td><%= query.display_time %></td>
          <td><%= query.method %></td>
          <td><%= query.display_keys %></td>
          <td></td>
          <td>
            <a href="/__rack_bug__/view_cache?<%= signed_params("key" => query.keys.first) %>" class="remote_call">View</a> |
            <a href="/__rack_bug__/delete_cache?<%= signed_params("key" => query.keys.first) %>" class="rb_delete_cache">Delete</a>
          </td>
        </tr>
        <% i += 1 %>
      <% end %>
    </tbody>
  </table>
<% end %>

<script type="text/javascript" charset="utf-8">
  jQuery(function () {
    jQuery("#rack_bug .rb_delete_cache").click(function (evt) {
      jQuery.ajax({
        url: this.href,
        beforeSend: function() {
          jQuery(evt.target).parent("td, th").addClass("rack_bug_spinner");
        },
        success: function () {
          jQuery(evt.target).parent("td, th").removeClass("rack_bug_spinner");
          jQuery(evt.target).replaceWith("Deleted");
        }
      });

      return false;
    });
  });
</script>