mirror of
https://github.com/jointakahe/takahe.git
synced 2024-11-14 03:11:46 +00:00
Fix notification pagination
This commit is contained in:
parent
20239b5cb7
commit
d5a6cbedd3
1 changed files with 7 additions and 7 deletions
|
@ -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 [
|
||||
|
|
Loading…
Reference in a new issue