Handle old IDs coming in for pagination

pull/387/head
Andrew Godwin 2023-01-09 09:08:16 -07:00
rodzic 4a1e375e3c
commit 024d956e5e
1 zmienionych plików z 8 dodań i 8 usunięć

Wyświetl plik

@ -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(