From d5a6cbedd3e056e8b9761829d5df46395a9555e1 Mon Sep 17 00:00:00 2001 From: Andrew Godwin Date: Sun, 11 Dec 2022 13:37:58 -0700 Subject: Fix notification pagination --- api/views/notifications.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'api/views') diff --git a/api/views/notifications.py b/api/views/notifications.py index 7b05d14..9f1f865 100644 --- a/api/views/notifications.py +++ b/api/views/notifications.py @@ -1,4 +1,4 @@ -from activities.models import PostInteraction, TimelineEvent +from activities.models import Post, PostInteraction, TimelineEvent from api import schemas from api.decorators import identity_required from api.views.base import api_router @@ -38,16 +38,16 @@ def notifications( .select_related("subject_post", "subject_post__author", "subject_identity") ) if max_id: - anchor_event = TimelineEvent.objects.get(pk=max_id) - events = events.filter(created__lt=anchor_event.created) + anchor_post = Post.objects.get(pk=max_id) + events = events.filter(created__lt=anchor_post.created) if since_id: - anchor_event = TimelineEvent.objects.get(pk=since_id) - events = events.filter(created__gt=anchor_event.created) + anchor_post = Post.objects.get(pk=since_id) + events = events.filter(created__gt=anchor_post.created) if min_id: # Min ID requires LIMIT events _immediately_ newer than specified, so we # invert the ordering to accomodate - anchor_event = TimelineEvent.objects.get(pk=min_id) - events = events.filter(created__gt=anchor_event.created).order_by("created") + anchor_post = Post.objects.get(pk=min_id) + events = events.filter(created__gt=anchor_post.created).order_by("created") events = list(events[:limit]) interactions = PostInteraction.get_event_interactions(events, request.identity) return [ -- cgit v1.2.3