{% extends "main.html" %}
{% load karaage_tags %}
{% load humanize filters %}


{% block title %}Software (stats){% endblock %}


{% block breadcrumbs %}
<div class="breadcrumbs"><a href='{% url "index" %}'>Home</a>&nbsp;›
    <a href="{% url 'kg_software_list' %}">Software</a>&nbsp;›
    <a href="{{ software.get_absolute_url }}">{{ software }}</a>&nbsp;›
    Statistics
</div>
{% endblock %}


{% block content %}
<div id="content-main">
    <p>{% date_filter start end %}</p>
    <div class="module">
        <h2>Versions</h2>
        <div class="table-container">
            <table>
                <thead>
                    <tr>
                        <th>Version</th>
                        <th>CPU Time</th>
                        <th>No. Jobs</th>
                    </tr>
                </thead>
                {% comment %}
                <tfoot>
                    <tr>
                        <td>Total</td>
                        <td class="right">{{ version_total.usage__sum|timeformat }}</td>
                        <td class="right">{{ version_totaljobs|intcomma }}</td>
                    </tr>
                </tfoot>
                {% endcomment %}
                <tbody>
                    {% for version in version_stats|dictsortreversed:"usage" %}
                    <tr>
                        <td><a href="{% url 'kg_software_version_stats' version.id %}?{{ querystring }}">{{ version }}</a></td>
                        <td class="right">{{ version.usage|timeformat }}</td>
                        <td class="right">{{ version.jobs|intcomma }}</td>
                    </tr>
                    {% endfor %}
                </tbody>
            </table>
        </div>
    </div>

    <div class="module">
        <h2>People</h2>
        <div class="table-container">
            <table>
                <thead>
                    <tr>
                        <th>Person</th>
                        <th>Institute</th>
                        <th>CPU Time</th>
                        <th>No. Jobs</th>
                    </tr>
                </thead>
                {% comment %}
                <tfoot>
                    <tr>
                        <td>Total</td>
                        <td class="right">{{ total|timeformat }}</td>
                        <td class="right">{{ total_jobs|intcomma }}</td>
                    </tr>
                </tfoot>
                {% endcomment %}
                <tbody>
                    {% for person in person_stats|dictsortreversed:"p_usage" %}
                    <tr>
                        <td><a href="{% url 'kg_person_detail' person.username %}">{{ person }}</a></td>
                        <td><a href="{% url 'kg_institute_detail' person.institute.pk %}">{{ person.institute }}</a></td>
                        <td class="right">{{ person.p_usage|timeformat }}</td>
                        <td class="right">{{ person.jobs|intcomma }}</td>
                    </tr>
                    {% endfor %}
                </tbody>
            </table>
        </div>
    </div>

    <div class="module">
        <h2>Person Institutes</h2>
        <div class="table-container">
            <table>
                <thead>
                    <tr>
                        <th>Institute</th>
                        <th>CPU Time</th>
                        <th>No. Jobs</th>
                    </tr>
                </thead>
                {% comment %}
                <tfoot>
                    <tr>
                        <td>Total</td>
                        <td class="right">{{ total|timeformat }}</td>
                        <td class="right">{{ total_jobs|intcomma }}</td>
                    </tr>
                </tfoot>
                {% endcomment %}
                <tbody>
                    {% for institute in person_institute_stats|dictsortreversed:"i_usage" %}
                    <tr>
                        <td><a href="{% url 'kg_institute_detail' institute.pk %}">{{ institute }}</a></td>
                        <td class="right">{{ institute.i_usage|timeformat }}</td>
                        <td class="right">{{ institute.jobs|intcomma }}</td>
                    </tr>
                    {% endfor %}
                </tbody>
            </table>
        </div>
    </div>

    <div class="module">
        <h2>Projects</h2>
        <div class="table-container">
            <table>
                <thead>
                    <tr>
                        <th>Project</th>
                        <th>Institute</th>
                        <th>CPU Time</th>
                        <th>No. Jobs</th>
                    </tr>
                </thead>
                {% comment %}
                <tfoot>
                    <tr>
                        <td>Total</td>
                        <td class="right">{{ total|timeformat }}</td>
                        <td class="right">{{ total_jobs|intcomma }}</td>
                    </tr>
                </tfoot>
                {% endcomment %}
                <tbody>
                    {% for project in project_stats|dictsortreversed:"p_usage" %}
                    <tr>
                        <td><a href="{% url 'kg_project_detail' project.pk %}">{{ project }}</a></td>
                        <td><a href="{% url 'kg_institute_detail' project.institute.pk %}">{{ project.institute }}</a></td>
                        <td class="right">{{ project.p_usage|timeformat }}</td>
                        <td class="right">{{ project.jobs|intcomma }}</td>
                    </tr>
                    {% endfor %}
                </tbody>
            </table>
        </div>
    </div>

    <div class="module">
        <h2>Project Institutes</h2>
        <div class="table-container">
            <table>
                <thead>
                    <tr>
                        <th>Institute</th>
                        <th>CPU Time</th>
                        <th>No. Jobs</th>
                    </tr>
                </thead>
                {% comment %}
                <tfoot>
                    <tr>
                        <td>Total</td>
                        <td class="right">{{ total|timeformat }}</td>
                        <td class="right">{{ total_jobs|intcomma }}</td>
                    </tr>
                </tfoot>
                {% endcomment %}
                <tbody>
                    {% for institute in project_institute_stats|dictsortreversed:"i_usage" %}
                    <tr>
                        <td><a href="{% url 'kg_institute_detail' institute.pk %}">{{ institute }}</a></td>
                        <td class="right">{{ institute.i_usage|timeformat }}</td>
                        <td class="right">{{ institute.jobs|intcomma }}</td>
                    </tr>
                    {% endfor %}
                </tbody>
            </table>
        </div>
    </div>

</div>
{% endblock %}
