Nicer stats

This commit is contained in:
terorie 2018-12-07 00:23:03 +01:00
parent e89eb6e3e0
commit 3335ec5f82
No known key found for this signature in database
GPG Key ID: C268B2BBDA2ABECB
3 changed files with 20 additions and 4 deletions

13
app.py
View File

@ -61,6 +61,19 @@ def datetime_format(value, format='%Y-%m-%d %H:%M:%S'):
return time.strftime(format, time.gmtime(value)) return time.strftime(format, time.gmtime(value))
@app.template.filetr("duration_format")
def duration_format(value):
delay = datetime.timedelta(seconds=value)
if (delay.days > 0):
out = str(delay).replace(" days, ", ":")
else:
out = "0:" + str(delay)
outAr = out.split(':')
outAr = ["%02d" % (int(float(x))) for x in outAr]
out = ":".join(outAr)
return out
@app.template_filter("from_timestamp") @app.template_filter("from_timestamp")
def from_timestamp(value): def from_timestamp(value):
return datetime.datetime.fromtimestamp(value) return datetime.datetime.fromtimestamp(value)

View File

@ -19,6 +19,9 @@ a {
.table td { .table td {
padding: 2px 0; padding: 2px 0;
} }
.table-numeric td {
text-align: end;
}
.bg-application { .bg-application {
background: #8FB847; background: #8FB847;

View File

@ -71,7 +71,7 @@
</table> </table>
<h4>Crawl server stats</h4> <h4>Crawl server stats</h4>
<table class="table table-striped"> <table class="table table-striped table-numeric">
<thead> <thead>
<tr> <tr>
<th>Server</th> <th>Server</th>
@ -87,10 +87,10 @@
<tr> <tr>
<td><b>{{ server }}</b></td> <td><b>{{ server }}</b></td>
<td>{{ crawl_server_stats[server].task_count }}</td> <td>{{ crawl_server_stats[server].task_count }}</td>
<td>{{ crawl_server_stats[server].time|round(2) }}s</td> <td>{{ crawl_server_stats[server].time | duration_format() }}</td>
<td>{{ crawl_server_stats[server].time_avg|round(2) }}s</td> <td>{{ crawl_server_stats[server].time_avg | duration_format() }}</td>
<td>{{ crawl_server_stats[server].file_count }}</td> <td>{{ crawl_server_stats[server].file_count }}</td>
<td>{{ crawl_server_stats[server].file_count_avg | round(2) }}</td> <td>{{ "%.2f" % crawl_server_stats[server].file_count_avg }}</td>
</tr> </tr>
{% endfor %} {% endfor %}
</tbody> </tbody>