added # matches on show persons page, and fixed issue with search OPT being hardcoded and not using those in the DB

This commit is contained in:
2022-01-16 00:55:23 +11:00
parent 05f12e78ea
commit 12726ed186
4 changed files with 37 additions and 18 deletions

View File

@@ -93,25 +93,31 @@ 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":
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
# 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']

View File

@@ -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)

View File

@@ -43,13 +43,6 @@
<div class="col-1">
<form id="_{{s[0]}}" method="POST" action="{{url_for('search')}}">
<input type="hidden" name="search_term" value="AI:{{s[0]}}">
<input type="hidden" name="noo" value="Oldest">
<input type="hidden" name="grouping" value="None">
<input type="hidden" name="how_many" value="50">
<input type="hidden" name="offset" value="0">
<input type="hidden" name="size" value="128">
<input type="hidden" name="folders" value="False">
<input type="hidden" name="cwd" value="/">
<a href="javascript:$('#_{{s[0]}}').submit()">{{s[0]}}</a></form>
</div>
<div class="col-1"><center>{{s[1]}}</center></div>

View File

@@ -2,13 +2,24 @@
{% block main_content %}
<h3>Show All People</h3>
<table id="person_table" class="table table-striped table-sm" data-toolbar="#toolbar" data-search="true">
<thead>
<tr class="table-primary"><th>Tag</th><th>Firstname(s)</th><th>Surname</th><th></th></tr>
<tr class="table-primary"><th>Tag</th><th>Faces Matched</th><th>Firstname(s)</th><th>Surname</th><th></th></tr>
</thead>
<tbody>
{% for person in persons %}
<tr><td><a href="{{url_for('person', id=person.id )}}">{{person.tag}}</td><td>{{person.firstname}}</td>
<tr><td><a href="{{url_for('person', id=person.id )}}">{{person.tag}}</td>
<td>
{% if person.num_matches %}
<form id="_{{person.tag}}" method="POST" action="{{url_for('search')}}">
<input type="hidden" name="search_term" value="AI:{{person.tag}}">
<a href="javascript:$('#_{{person.tag}}').submit()">{{person.num_matches}} matches</a></form>
{% else %}
No matches
{% endif %}
</td>
<td>{{person.firstname}}</td>
<td>{{person.surname}}</td>
<td>
{% for refimg in person.refimg %}