{% extends "base.html" %}
{% block content %}
<h1>
    Reports Matrix : {{ title }}
</h1>

<table class="mx-table">
    {%- set report_names = matrix.report_order() %}
    {%- set n_reports = report_names.__len__() %}
    {%- if n_reports > 0 %}
    <tr><!-- top row, stats and each matrix axis -->
        <td> <!-- stats -->
            <table class="stats-table">
                {%- for outcome in matrix.result_stats %}
                <tr>
                    <th class="{{outcome}}">{{outcome.title()}}</th>
                    <td>{{matrix.result_stats[outcome]}}</td>
                </tr>
                {%- endfor %}
            </table>
        </td>
        <td style="text-align: left">
    {%- if show_time_usage %}
        <b>Slowest suites:</b>
        <table>
        {%- set times = matrix.class_time_breakdown() %}
        {%- set total_time = matrix.class_timings.values()|sum %}
        {%- set breakdown_total = 0 %}
            <tr>
                <th colspan="2">CPU time (mins)</th><th>Suite Name</th>
            </tr>
        {%- for classname, pct in (times|dictsort(False, by="value", reverse=True))[:5] %}
            {%- set breakdown_total = breakdown_total + pct %}
            <tr><td style="text-align: right">{{ (100 * pct)|round }}%</td>
                <td style="text-align: right">{{ ((pct * total_time) / 60)|round(1) }}</td>
                <td><a href="#{{ matrix.class_anchors[classname] }}">{{ classname }}</a></td></tr>
        {%- endfor %}
        </table>
    {%- endif %}
        </td>
    {%- for n in range(n_reports) %}
        <td class="{% if n % 2 == 0 %}mx-even{% endif %}">
            <div class="mx-ax-vertical">
                <a href="{{report_names[n]}}.html">{{matrix.short_axis(report_names[n])}}</a>
            </div>
        </td>
    {%- endfor %}
    </tr>
    <tr><td colspan="{{ 2 + n_reports }}"></td></tr>
    {%- endif %}

    <!-- test results by class/test -->
    {%- for classname in matrix.classes.keys()|sort %}
    <tr>
        <th class="mx-cls" colspan="2"><a id="{{ matrix.class_anchors[classname] }}"></a>{{ classname }} ({{ (matrix.class_timings[classname] / 60)|round(1) }} mins)</th>
        {%- for n in range(n_reports) %}
        <td class="mx-ax-line {% if n % 2 == 1 %}mx-even{% endif %}"></td>
        {%- endfor %}
    </tr>
    {%- for casename in matrix.casenames[classname] %}
    {%- set xcasedisplay = casename %}
    {%- if xcasedisplay|length > 80 %}
        {%- set xcasedisplay = casename|truncate(60) ~ casename[-16:] %}
    {%- endif %}
    {%- set xcase = matrix.cases[classname][casename] %}
    <tr>
        <th class="mx-name">{{xcasedisplay}}</th>
        <td class="mx-name mx-res-combined">{{ matrix.combined_result_list(classname, casename)[1] }}</td>
        {%- for n in range(n_reports) %}
        {%- set axis = report_names[n] %}
        {%- set line_class="mx-ax-line" %}
        {%- if axis in xcase %}
            {%- set line_class = line_class ~ " mx-res-" ~ xcase[axis].outcome() %}
        {%- endif %}
        <td class="{{ line_class }}">
        {%- if axis in xcase %}
            <a href="{{axis}}.html#{{xcase[axis].anchor()}}">
                <div class="mx-res">{{ matrix.short_outcome(xcase[axis].outcome()) }}</div>
            </a>
        {%- endif %}
        </td>
        {%- endfor %}
        {%- endfor %}
    </tr>
    {%- endfor %}
</table>
{% endblock %}
