From 12726ed1869ed79963875a5a7ea496033ffa1bb7 Mon Sep 17 00:00:00 2001 From: Damien De Paoli Date: Sun, 16 Jan 2022 00:55:23 +1100 Subject: [PATCH] added # matches on show persons page, and fixed issue with search OPT being hardcoded and not using those in the DB --- options.py | 24 +++++++++++++++--------- person.py | 9 +++++++++ templates/aistats.html | 7 ------- templates/persons.html | 15 +++++++++++++-- 4 files changed, 37 insertions(+), 18 deletions(-) diff --git a/options.py b/options.py index 45a0c1a..9e3a2c0 100644 --- a/options.py +++ b/options.py @@ -93,26 +93,32 @@ class Options(PA): self.cwd='static/' + self.path_type self.root=self.cwd - # the above are defaults, if we are here, then we have current values, use them instead + # the above are defaults, if we are here, then we have current values, use them instead if they are set -- AI: searches dont set them so then we use those in the DB first if request.method=="POST": - self.noo=request.form['noo'] - self.how_many=request.form['how_many'] - self.offset=int(request.form['offset']) - self.grouping=request.form['grouping'] + if 'noo' in request.form: + self.noo=request.form['noo'] + if 'how_many' in request.form: + self.how_many=request.form['how_many'] + if 'offset' in request.form: + self.offset=int(request.form['offset']) + if 'grouping' in request.form: + self.grouping=request.form['grouping'] # this can be null if we come from view by details - if request.form['size']: + if 'size' in request.form: self.size = request.form['size'] # seems html cant do boolean, but uses strings so convert - if request.form['folders'] == "False": + if 'folders' not in request.form or request.form['folders'] == "False": self.folders=False - if request.form['folders'] == "True": + elif request.form['folders'] == "True": self.folders=True # have to force grouping to None if we flick to folders from a flat # view with grouping (otherwise we print out group headings for # child content that is not in the CWD) self.grouping=None - self.cwd = request.form['cwd'] + # possible to not be set for an AI: search + if 'cwd' in request.form: + self.cwd = request.form['cwd'] if 'fullscreen' in request.form: self.fullscreen=request.form['fullscreen'] else: diff --git a/person.py b/person.py index 8f2d076..097049e 100644 --- a/person.py +++ b/person.py @@ -95,6 +95,15 @@ class PersonForm(FlaskForm): @login_required def persons(): persons = Person.query.all() + # get the num matches for each person too, and allow link for it + stats = list( 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" ) ) + for p in persons: + if not p.refimg: + continue + for s in stats: + if p.tag == s[0]: + p.num_matches = s[1]; + break return render_template("persons.html", persons=persons) diff --git a/templates/aistats.html b/templates/aistats.html index 0096156..97b0926 100644 --- a/templates/aistats.html +++ b/templates/aistats.html @@ -43,13 +43,6 @@
- - - - - - - {{s[0]}}
{{s[1]}}
diff --git a/templates/persons.html b/templates/persons.html index c2048a5..79b3a26 100644 --- a/templates/persons.html +++ b/templates/persons.html @@ -2,13 +2,24 @@ {% block main_content %}

Show All People

+ - + {% for person in persons %} - + + +
TagFirstname(s)Surname
TagFaces MatchedFirstname(s)Surname
{{person.tag}}{{person.firstname}}
{{person.tag}} + {% if person.num_matches %} +
+ + {{person.num_matches}} matches
+ {% else %} + No matches + {% endif %} +
{{person.firstname}} {{person.surname}} {% for refimg in person.refimg %}