Separately count photo results to fix included albums counting.
I'm currently running an experiment where albums are also included in search results, but they don't cost you any of your limit parameter. So the len(results) was often bigger than limit and tricking this paginator into thinking we needed a next page when really we didn't. This workaround can be undone when I decide how to make the album results more official.
This commit is contained in:
parent
cfb48a8d11
commit
b0dcc6d3c6
1 changed files with 6 additions and 3 deletions
|
@ -398,11 +398,14 @@ def get_search_core():
|
|||
|
||||
warnings = set()
|
||||
search_results = []
|
||||
search_results_photo_count = 0
|
||||
for item in search_generator:
|
||||
if isinstance(item, etiquette.objects.WarningBag):
|
||||
warnings.update(item.warnings)
|
||||
else:
|
||||
continue
|
||||
search_results.append(item)
|
||||
if isinstance(item, etiquette.objects.Photo):
|
||||
search_results_photo_count += 1
|
||||
|
||||
# TAGS ON THIS PAGE
|
||||
total_tags = set()
|
||||
|
@ -416,7 +419,7 @@ def get_search_core():
|
|||
original_params = request.args.to_dict()
|
||||
original_params['limit'] = limit
|
||||
|
||||
if limit and len(search_results) >= limit:
|
||||
if limit and search_results_photo_count >= limit:
|
||||
next_params = original_params.copy()
|
||||
next_params['offset'] = offset + limit
|
||||
next_params = helpers.dict_to_params(next_params)
|
||||
|
|
Loading…
Reference in a new issue