[mod] /stats : add reliability column and sort by column links

This commit is contained in:
Alexandre Flament 2021-04-22 17:47:53 +02:00
parent c54bf42cb9
commit 09e7ecdce2
7 changed files with 148 additions and 37 deletions

View file

@ -1,6 +1,5 @@
{% extends "oscar/base.html" %}
{% block styles %}
<link rel="stylesheet" href="{{ url_for('static', filename='css/charts.min.css') }}" type="text/css" />
<style>
#engine-times {
--labels-size: 20rem;
@ -12,6 +11,15 @@
</style>
{% endblock %}
{% block title %}{{ _('stats') }} - {% endblock %}
{%- macro th_sort(column_order, column_name) -%}
{% if column_order==sort_order %}
{{ column_name }} {{ icon('chevron-down') }}
{% else %}
<a href="{{ url_for('stats', sort=column_order) }}">{{ column_name }}
{% endif %}
{%- endmacro -%}
{% block content %}
<div class="container-fluid">
<h1>{{ _('Engine stats') }}</h1>
@ -25,27 +33,33 @@
{% else %}
<table class="table table-hover table-condensed table-striped">
<tr>
<th scope="col" style="width:20rem;">{{ _("Engine name") }}</th>
<th scope="col" style="width:7rem; text-align: right;">{{ _('Scores') }}</th>
<th scope="col">{{ _('Number of results') }}</th>
<th scope="col">{{ _('Response time') }}</th>
<th scope="col" style="width:20rem;">{{ th_sort('name', _("Engine name")) }}</th>
<th scope="col" style="width:7rem; text-align: right;">{{ th_sort('score', _('Scores')) }}</th>
<th scope="col">{{ th_sort('result_count', _('Result count')) }}</th>
<th scope="col">{{ th_sort('time', _('Response time')) }}</th>
<th scope="col" style="text-align: right;">{{ th_sort('reliability', _('Reliability')) }}</th>
</tr>
{% for engine_stat in engine_stats.get('time', []) %}
<tr>
<td>{{ engine_stat.name }}</td>
<td style="text-align: right;">
{% if engine_stat.score %}
<span aria-labelledby="{{engine_stat.name}}_score" >{{ engine_stat.score|round(1) }}</span>
<div class="engine-tooltip text-left" role="tooltip" id="{{engine_name}}_score">{{- "" -}}
<p>{{ _('Scores per result') }}: {{ engine_stat.score_per_result | round(3) }}</p>
</div>
{% endif %}
</td>
<td>
{%- if engine_stat.result_count -%}
<span class="stacked-bar-chart-value">{{- engine_stat.result_count | int -}}</span>{{- "" -}}
<span class="stacked-bar-chart" aria-labelledby="{{engine_stat.name}}_chart_result_count" aria-hidden="true">{{- "" -}}
<span style="width: calc(max(2px, 100%*{{ (engine_stat.result_count / engine_stats.max_result_count )|round(3) }}))" class="stacked-bar-chart-serie1"></span>{{- "" -}}
</span>{{- "" -}}
</span>
{%- endif -%}
</td>
<td>
{%- if engine_stat.total -%}
<span class="stacked-bar-chart-value">{{- engine_stat.total | round(1) -}}</span>{{- "" -}}
<span class="stacked-bar-chart" aria-labelledby="{{engine_stat.name}}_chart" aria-hidden="true">{{- "" -}}
<span style="width: calc(max(2px, 100%*{{ (engine_stat.http / engine_stats.max_time )|round(3) }}))" class="stacked-bar-chart-serie1"></span>{{- "" -}}
@ -79,7 +93,9 @@
</tr>
</table>
</div>
{%- endif -%}
</td>
<td style="text-align: right;"> {{ engine_reliabilities.get(engine_stat.name, {}).get('reliablity') }}</td>
</tr>
{% endfor %}
</table>