Integrate author search into the query instead of postprocessing.
Much faster this way.
This commit is contained in:
parent
38e72c0c3a
commit
557f78eb02
2 changed files with 16 additions and 4 deletions
|
@ -728,6 +728,7 @@ class PDBPhotoMixin:
|
||||||
notnulls,
|
notnulls,
|
||||||
minimums,
|
minimums,
|
||||||
maximums,
|
maximums,
|
||||||
|
author_ids=authors,
|
||||||
mmf_results=mmf_results,
|
mmf_results=mmf_results,
|
||||||
)
|
)
|
||||||
print(query[:200])
|
print(query[:200])
|
||||||
|
@ -765,9 +766,9 @@ class PDBPhotoMixin:
|
||||||
#print('Failed mimetype')
|
#print('Failed mimetype')
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if authors and photo.author_id not in authors:
|
# if authors and photo.author_id not in authors:
|
||||||
#print('Failed author')
|
# #print('Failed author')
|
||||||
continue
|
# continue
|
||||||
|
|
||||||
if filename_tree and not filename_tree.evaluate(photo.basename.lower()):
|
if filename_tree and not filename_tree.evaluate(photo.basename.lower()):
|
||||||
#print('Failed filename')
|
#print('Failed filename')
|
||||||
|
|
|
@ -6,10 +6,21 @@ from . import objects
|
||||||
from voussoirkit import expressionmatch
|
from voussoirkit import expressionmatch
|
||||||
|
|
||||||
|
|
||||||
def build_query(orderby, notnulls, minimums, maximums, mmf_results=None):
|
def build_query(
|
||||||
|
orderby,
|
||||||
|
notnulls,
|
||||||
|
minimums,
|
||||||
|
maximums,
|
||||||
|
author_ids=None,
|
||||||
|
mmf_results=None,
|
||||||
|
):
|
||||||
query = ['SELECT * FROM photos']
|
query = ['SELECT * FROM photos']
|
||||||
wheres = []
|
wheres = []
|
||||||
|
|
||||||
|
if author_ids:
|
||||||
|
notnulls.add('author_id')
|
||||||
|
wheres.append('author_id in %s' % helpers.sql_listify(author_ids))
|
||||||
|
|
||||||
if mmf_results:
|
if mmf_results:
|
||||||
wheres.append('id %s %s' % (mmf_results['operator'], helpers.sql_listify(mmf_results['photoids'])))
|
wheres.append('id %s %s' % (mmf_results['operator'], helpers.sql_listify(mmf_results['photoids'])))
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue