diff --git a/tildes/tildes/models/pagination.py b/tildes/tildes/models/pagination.py index 9727502..1462519 100644 --- a/tildes/tildes/models/pagination.py +++ b/tildes/tildes/models/pagination.py @@ -112,6 +112,13 @@ class PaginatedQuery(ModelQuery): return self + def remove_before_after(self): + """Remove all before or after restrictions from query""" + self.before_id = None + self.after_id = None + + return self + def _apply_before_or_after(self) -> PaginatedQuery: """Apply the "before" or "after" restrictions if necessary.""" # pylint: disable=assignment-from-no-return @@ -229,6 +236,9 @@ class PaginatedResults: self.has_next_page = False self.has_prev_page = False + # fetch total number of results without pagination + self.total_count = len(query.remove_before_after().all()) + def __iter__(self) -> Iterator[Any]: """Iterate over the results.""" return iter(self.results) diff --git a/tildes/tildes/templates/search.jinja2 b/tildes/tildes/templates/search.jinja2 index 528be15..d16642d 100644 --- a/tildes/tildes/templates/search.jinja2 +++ b/tildes/tildes/templates/search.jinja2 @@ -30,7 +30,7 @@ {% block sidebar %} {{ search_form(search, group) }} -