parent
e65f85becb
commit
96e3bac55c
13
lookup.py
13
lookup.py
|
@ -9,10 +9,10 @@ import traceback
|
||||||
import typing
|
import typing
|
||||||
from time import time
|
from time import time
|
||||||
|
|
||||||
import sqlalchemy
|
|
||||||
import sqlalchemy.exc
|
import sqlalchemy.exc
|
||||||
import werkzeug.debug.tbtools
|
import werkzeug.debug.tbtools
|
||||||
from flask import Flask, jsonify, redirect, render_template, request, url_for
|
from flask import Flask, jsonify, redirect, render_template, request, url_for
|
||||||
|
from sqlalchemy import func
|
||||||
from sqlalchemy.orm.query import Query
|
from sqlalchemy.orm.query import Query
|
||||||
from werkzeug.wrappers import Response
|
from werkzeug.wrappers import Response
|
||||||
|
|
||||||
|
@ -332,12 +332,15 @@ def reports() -> str:
|
||||||
"""Reports page with various statistics."""
|
"""Reports page with various statistics."""
|
||||||
log_count = model.LookupLog.query.count()
|
log_count = model.LookupLog.query.count()
|
||||||
|
|
||||||
log_start_time = database.session.query(
|
log_start_time, average_response_time = database.session.query(
|
||||||
sqlalchemy.func.min(model.LookupLog.dt)
|
func.min(model.LookupLog.dt), func.avg(model.LookupLog.response_time_ms)
|
||||||
).scalar()
|
).one()
|
||||||
|
|
||||||
return render_template(
|
return render_template(
|
||||||
"reports.html", log_count=log_count, log_start_time=log_start_time
|
"reports.html",
|
||||||
|
log_count=log_count,
|
||||||
|
log_start_time=log_start_time,
|
||||||
|
average_response_time=average_response_time,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,8 @@
|
||||||
|
|
||||||
<p>Total lookups processed: {{ "{:,d}".format(log_count) }}</p>
|
<p>Total lookups processed: {{ "{:,d}".format(log_count) }}</p>
|
||||||
|
|
||||||
|
<p>Average response time: {{ average_response_time | int }} milliseconds</p>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
Loading…
Reference in a new issue