{% load i18n %}
<h4>{% translate "Summary" %}</h4>
<table>
  <thead>
    <tr>
      <th>{% translate "Total calls" %}</th>
      <th>{% translate "Total time" %}</th>
      <th>{% translate "Cache hits" %}</th>
      <th>{% translate "Cache misses" %}</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>{{ total_calls }}</td>
      <td>{{ total_time|floatformat:"2" }} ms</td>
      <td>{{ hits }}</td>
      <td>{{ misses }}</td>
    </tr>
  </tbody>
</table>
<p class="djdt-cache-note">
    Cache hit/miss statistics for <code>cache.get()</code> calls may not always be accurate.
    See <a target="_blank" href="https://github.com/django-commons/django-debug-toolbar/discussions/2441">the discussion</a>
    for details and to share feedback about improving cache hit/miss tracking.
</p>
<h4>{% translate "Commands" %}</h4>
<table>
  <thead>
    <tr>
      {% for name in counts.keys %}
        <th>{{ name }}</th>
      {% endfor %}
    </tr>
  </thead>
  <tbody>
    <tr>
      {% for value in counts.values %}
        <td>{{ value }}</td>
      {% endfor %}
    </tr>
  </tbody>
</table>
{% if calls %}
  <h4>{% translate "Calls" %}</h4>
  <table>
    <thead>
      <tr>
        <th colspan="2">{% translate "Time" %}</th>
        <th>{% translate "Type" %}</th>
        <th>{% translate "Arguments" %}</th>
        <th>{% translate "Keyword arguments" %}</th>
        <th>{% translate "Backend" %}</th>
      </tr>
    </thead>
    <tbody>
      {% for call in calls %}
        <tr id="cacheMain_{{ forloop.counter }}">
          <td class="djdt-toggle">
            <button class="djToggleSwitch" data-toggle-name="cacheMain" data-toggle-id="{{ forloop.counter }}">+</button>
          </td>
          <td>{{ call.time|floatformat:"2" }}ms</td>
          <td>{{ call.name|escape }}</td>
          <td>{{ call.args|escape }}</td>
          <td>{{ call.kwargs|escape }}</td>
          <td>{{ call.backend }}</td>
        </tr>
        <tr class="djUnselected djToggleDetails_{{ forloop.counter }}" id="cacheDetails_{{ forloop.counter }}">
          <td colspan="1"></td>
          <td colspan="5"><pre class="djdt-stack">{{ call.trace|safe }}</pre></td>
        </tr>
      {% endfor %}
    </tbody>
  </table>
{% endif %}
