diff --git a/photoapp/daemon.py b/photoapp/daemon.py index c9b69ef..90d5c07 100644 --- a/photoapp/daemon.py +++ b/photoapp/daemon.py @@ -1,5 +1,6 @@ import os import math +import time import logging import cherrypy from urllib.parse import urlparse @@ -445,6 +446,7 @@ class SearchView(object): set_after=None, keywords_title=None, keywords_description=None, + keywords_filename=None, operation=None, add_tag=None, remove_tag=None, @@ -511,6 +513,10 @@ class SearchView(object): base = base \ .filter(PhotoSet.description.like("%{}%".format(keywords_description))) + if keywords_filename: + base = base \ + .filter(PhotoSet.id.in_(db.query(Photo.set_id).filter(Photo.fname.like("%{}%".format(keywords_filename))))) + base = base \ .order_by(PhotoSet.date.desc()) @@ -551,9 +557,13 @@ class SearchView(object): # or is it Fine since we don't re-use any orm-mapped objects from above? db.expire_all() + query_start = time.time() + total_sets = build_query(db.query(func.count(PhotoSet.id))).scalar() images = build_query(db.query(PhotoSet)).offset(pgsize * page).limit(pgsize).all() + query_duration = time.time() - query_start + yield self.master.render( "search.html", include_tags=include_tags, @@ -568,7 +578,9 @@ class SearchView(object): after=after.strftime(FMT_TIME_SEARCH) if after else "", keywords_title=keywords_title or "", keywords_description=keywords_description or "", + keywords_filename=keywords_filename or "", now=datetime.now().strftime(FMT_TIME_SEARCH), + query_duration=query_duration, ) diff --git a/templates/search.html b/templates/search.html index c4546a6..f48a5e6 100644 --- a/templates/search.html +++ b/templates/search.html @@ -54,6 +54,12 @@ +
Options
@@ -149,10 +155,7 @@ {% endfor %} {% endif %} - - - - + {% endblock %}