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 %} +
Logging started {{ log_start_time.strftime("%a %d %b %Y") }}
+ +Total lookups processed: {{ "{:,d}".format(log_count) }}
+ +