From 8bfe86ee8258961938e21a36938ce76fbe9dcf3d Mon Sep 17 00:00:00 2001 From: Edward Betts Date: Sun, 10 Dec 2023 10:32:15 +0000 Subject: [PATCH] Add reports page Closes: #7 --- lookup.py | 15 +++++++++++++++ templates/reports.html | 17 +++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 templates/reports.html diff --git a/lookup.py b/lookup.py index 62fde8c..cf4eb59 100755 --- a/lookup.py +++ b/lookup.py @@ -8,6 +8,7 @@ import sys import traceback import typing +import sqlalchemy import sqlalchemy.exc import werkzeug.debug.tbtools from flask import Flask, jsonify, redirect, render_template, request, url_for @@ -323,5 +324,19 @@ def detail_page() -> Response | str: return build_detail_page(lat, lon) +@app.route("/reports") +def reports() -> str: + """Reports page with various statistics.""" + log_count = model.LookupLog.query.count() + + log_start_time = database.session.query( + sqlalchemy.func.min(model.LookupLog.dt) + ).scalar() + + return render_template( + "reports.html", log_count=log_count, log_start_time=log_start_time + ) + + if __name__ == "__main__": app.run(host="0.0.0.0") diff --git a/templates/reports.html b/templates/reports.html new file mode 100644 index 0000000..ce4e805 --- /dev/null +++ b/templates/reports.html @@ -0,0 +1,17 @@ +{% extends "base.html" %} + +{% block title %}Geocode to Commons: Reports{% endblock %} + +{% block content %} +
+

Geocode reports

+ +

Back to index

+ +

Logging started {{ log_start_time.strftime("%a %d %b %Y") }}

+ +

Total lookups processed: {{ "{:,d}".format(log_count) }}

+ +
+ +{% endblock %}