From 78713a6767d67a919cb1710432b8f41fd0824119 Mon Sep 17 00:00:00 2001 From: Damien De Paoli Date: Wed, 30 Jun 2021 14:28:15 +1000 Subject: [PATCH] updated stats to use new face tables and be more useful now amount of matches is in the thousands --- ai.py | 15 ++++----------- templates/aistats.html | 10 +++------- 2 files changed, 7 insertions(+), 18 deletions(-) diff --git a/ai.py b/ai.py index d551b9b..9112953 100644 --- a/ai.py +++ b/ai.py @@ -5,12 +5,13 @@ from main import db, app, ma from sqlalchemy import Sequence from sqlalchemy.exc import SQLAlchemyError from status import st, Status -from files import Entry, File, FileRefimgLink +from files import Entry, File from person import Person, PersonRefimgLink from refimg import Refimg from flask_login import login_required, current_user from job import Job, JobExtra, Joblog, NewJob +from face import Face, FaceFileLink, FaceRefimgLink # pylint: disable=no-member @@ -21,16 +22,8 @@ from job import Job, JobExtra, Joblog, NewJob @app.route("/aistats", methods=["GET", "POST"]) @login_required def aistats(): - tmp=db.session.query(Entry,Person).join(File).join(FileRefimgLink).join(Refimg).join(PersonRefimgLink).join(Person).filter(FileRefimgLink.matched==True).all() - entries=[] - last_fname="" - for e, p in tmp: - if last_fname != e.name: - entry = { 'name': e.name, 'people': [] } - entries.append( entry ) - last_fname = e.name - entry['people'].append( { 'tag': p.tag } ) - return render_template("aistats.html", page_title='Placeholder', entries=entries) + stats = db.session.execute( "select p.tag, count(f.id) from person p, face f, face_file_link ffl, face_refimg_link frl, person_refimg_link prl where p.id = prl.person_id and prl.refimg_id = frl.refimg_id and frl.face_id = ffl.face_id and ffl.face_id = f.id group by p.tag" ) + return render_template("aistats.html", page_title='AI Statistics', stats=stats) ################################################################################ diff --git a/templates/aistats.html b/templates/aistats.html index 0797cb6..5af9c62 100644 --- a/templates/aistats.html +++ b/templates/aistats.html @@ -3,13 +3,9 @@ {% block main_content %}

Basic AI stats

- - {% for e in entries %} - + + {% for s in stats %} + {% endfor %}
FileAI Matched people
{{e.name}} - {% for p in e.people %} - {{p.tag}} - {% endfor %} -
Person (tag)Number of files matched
{{s[0]}}{{s[1]}}
{% endblock main_content %}