From 6317277c96e6828f8518033791f709e708dfc29e Mon Sep 17 00:00:00 2001 From: Edward Betts Date: Sun, 29 Sep 2019 11:23:07 +0100 Subject: [PATCH] More detail on the list edits page. --- app.py | 16 +++++++++++++++- templates/list_edits.html | 8 ++++++-- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/app.py b/app.py index 6db2a75..7054544 100755 --- a/app.py +++ b/app.py @@ -9,6 +9,7 @@ from requests_oauthlib import OAuth1Session from urllib.parse import urlencode from werkzeug.exceptions import InternalServerError from werkzeug.debug.tbtools import get_current_traceback +from sqlalchemy import func, distinct import requests.exceptions import requests import lxml.html @@ -496,7 +497,20 @@ def get_other(entity): @app.route("/admin/edits") def list_edits(): edit_list = Edit.query.order_by(Edit.timestamp) - return render_template('list_edits.html', edits=Edit.query, edit_list=edit_list) + + painting_count = (database.session + .query(func.count(distinct(Edit.painting_id))) + .scalar()) + + user_count = (database.session + .query(func.count(distinct(Edit.username))) + .scalar()) + + return render_template('list_edits.html', + edits=Edit.query, + edit_list=edit_list, + painting_count=painting_count, + user_count=user_count) @app.route("/next/Q") def next_page(item_id): diff --git a/templates/list_edits.html b/templates/list_edits.html index b0f1119..36d1971 100644 --- a/templates/list_edits.html +++ b/templates/list_edits.html @@ -3,7 +3,11 @@ {% block content %}
-

This tool has been used to save {{ edits.count() }} edits.

+

This tool has been used to add a total of {{ edits.count() }} depicts statements.

+ +

{{ user_count }} users have tried this tool.

+ +

{{ painting_count }} paintings have been cataloged.

@@ -22,7 +26,7 @@ ({{ edit.painting_qid }}) - + {% endfor %}
{{ edit.depicts.label }} ({{ edit.depicts_qid }}){{ edit.timestamp.strftime('%H:%M %a, %d %b %Y') }}{{ edit.timestamp.strftime('%Y %b %d %H:%M') }}