{% extends "layout.html" %}

{% block title %}Statistics for tag {{ tag.tag }}{% endblock %}

{% block head %}
  <script type="text/javascript" src="/static/js/toggle.js"></script>
{% endblock %}

{% block breadcrumb %}
  {{ macros.breadcrumb(breadcrumb) }}
{% endblock %}

{% block hamburger %}
  {{ macros.tagHamburger(tag, neighbours, "/statistics", dependencies) }}
{% endblock %}

{% block body %}
<h2>Statistics for tag <span class="tag">{{ tag.tag }}</span></h2>
<p><a href="/tag/{{ tag.tag }}">Go back to the tag's page</a>.

{% if creation and update %}
  <table class="table table-sm">
    <tr>
      <th class="border-top-0">tag creation</th>
      <th class="border-top-0">last update</th>
    </tr>
    <tr>
      <td>{{ creation.strftime("%b %-d, %Y") }}</td>
      <td>{{ update.strftime("%b %-d, %Y") }}</td>
      <td><a href="/tag/{{ tag.tag }}/history">more history</a>
    </tr>
  </table>
{% endif %}

{% if statistics %}
<h3>Complexity measure</h3>
<table class="table table-striped table-sm table-hover">
  <thead>
    <tr>
      <th>metric</th>
      <th>value</th>
    </tr>
  </thead>
  <tbody>
    {% if statistics.proof != -1 %}
    <tr>
      <td>number of results in proof</td>
      <td>{{ statistics.proof }}</td>
    </tr>
    {% endif %}
    {% if statistics.preliminaries != -1 %}
    <tr>
      <td>number of results used in preliminary results</td>
      <td>{{ statistics.preliminaries }}</td>
    </tr>
    {% endif %}
    {% if statistics.chapters != -1 %}
    <tr>
      <td>number of chapters used</td>
      <td>{{ statistics.chapters }}</td>
    </tr>
    {% endif %}
    {% if statistics.sections != -1 %}
    <tr>
      <td>number of sections used</td>
      <td>{{ statistics.sections }}</td>
    </tr>
    {% endif %}
    {% if statistics.consequences != -1 %}
    <tr>
      <td>number of results (indirectly) using this tag</td>
      <td>{{ statistics.consequences }}</td>
    </tr>
    {% endif %}
  </tbody>
</table>
{% else %}
<h3>No computed statistics for this tag</h3><br/>
{% endif %}

{% if dependencies | length > 0 %}
<h3 id="dependencies">Tags (directly) using this result</h3>
<ul>
{% for dependency in dependencies %}
  <li>{{ dependency.tag.type | capitalize }} <a href="/tag/{{ dependency.tag.tag }}" data-tag="{{ dependency.tag.tag }}">{{ dependency.tag.ref }}</a>
  in {{ dependency.parent.type | capitalize }} <a href="/tag/{{ dependency.parent.tag }}" data-tag="{{ dependency.parent.tag }}">{{ dependency.parent.ref }}</a>: {{ dependency.parent.name }}
    <br>(go to <a href="/tag/{{ dependency.tag.tag }}/statistics">statistics</a>)
{% endfor %}
</ul>
{% else %}
<h3 id="dependencies">No tags currently use this result</h3>
{% endif %}

{% endblock %}

{% block sidebar %}
  {{ macros.tagSidebar(tag, neighbours, "/statistics", dependencies, filename) }}
{% endblock %}

