From 024d956e5e5252e87434a57acb3bbc21634ed28d Mon Sep 17 00:00:00 2001 From: Andrew Godwin Date: Mon, 9 Jan 2023 09:08:16 -0700 Subject: [PATCH] Handle old IDs coming in for pagination --- api/pagination.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/api/pagination.py b/api/pagination.py index 31b0ecb..275653a 100644 --- a/api/pagination.py +++ b/api/pagination.py @@ -136,13 +136,13 @@ class MastodonPaginator: since_id: str | None, limit: int | None, ) -> PaginationResult: - if max_id: + # These "does not start with interaction" checks can be removed after a + # couple months, when clients have flushed them out. + if max_id and not max_id.startswith("interaction"): queryset = queryset.filter(id__lt=max_id) - - if since_id: + if since_id and not since_id.startswith("interaction"): queryset = queryset.filter(id__gt=since_id) - - if min_id: + if min_id and not min_id.startswith("interaction"): # Min ID requires items _immediately_ newer than specified, so we # invert the ordering to accommodate queryset = queryset.filter(id__gt=min_id).order_by("id") @@ -167,19 +167,19 @@ class MastodonPaginator: The home timeline requires special handling where we mix Posts and PostInteractions together. """ - if max_id: + if max_id and not max_id.startswith("interaction"): queryset = queryset.filter( models.Q(subject_post_id__lt=max_id) | models.Q(subject_post_interaction_id__lt=max_id) ) - if since_id: + if since_id and not since_id.startswith("interaction"): queryset = queryset.filter( models.Q(subject_post_id__gt=since_id) | models.Q(subject_post_interaction_id__gt=since_id) ) - if min_id: + if min_id and not min_id.startswith("interaction"): # Min ID requires items _immediately_ newer than specified, so we # invert the ordering to accommodate queryset = queryset.filter(