mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-11-23 01:51:08 +00:00
Merge pull request #1006 from bookwyrm-social/queryset-performance
Queryset performance
This commit is contained in:
commit
247850e49d
4 changed files with 9 additions and 3 deletions
|
@ -29,4 +29,6 @@
|
||||||
<div>{% blocktrans with username=user.display_name %}{{ username }} has no followers{% endblocktrans %}</div>
|
<div>{% blocktrans with username=user.display_name %}{{ username }} has no followers{% endblocktrans %}</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{% include 'snippets/pagination.html' with page=followers path=request.path %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
|
@ -29,4 +29,6 @@
|
||||||
<div>{% blocktrans with username=user|username %}{{ username }} isn't following any users{% endblocktrans %}</div>
|
<div>{% blocktrans with username=user|username %}{{ username }} isn't following any users{% endblocktrans %}</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{% include 'snippets/pagination.html' with page=following path=request.path %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
|
@ -16,7 +16,7 @@ class Notifications(View):
|
||||||
notifications = request.user.notification_set.all().order_by("-created_date")
|
notifications = request.user.notification_set.all().order_by("-created_date")
|
||||||
unread = [n.id for n in notifications.filter(read=False)]
|
unread = [n.id for n in notifications.filter(read=False)]
|
||||||
data = {
|
data = {
|
||||||
"notifications": notifications,
|
"notifications": notifications[:50],
|
||||||
"unread": unread,
|
"unread": unread,
|
||||||
}
|
}
|
||||||
notifications.update(read=True)
|
notifications.update(read=True)
|
||||||
|
|
|
@ -106,10 +106,11 @@ class Followers(View):
|
||||||
if is_api_request(request):
|
if is_api_request(request):
|
||||||
return ActivitypubResponse(user.to_followers_activity(**request.GET))
|
return ActivitypubResponse(user.to_followers_activity(**request.GET))
|
||||||
|
|
||||||
|
paginated = Paginator(user.followers.all(), PAGE_LENGTH)
|
||||||
data = {
|
data = {
|
||||||
"user": user,
|
"user": user,
|
||||||
"is_self": request.user.id == user.id,
|
"is_self": request.user.id == user.id,
|
||||||
"followers": user.followers.all(),
|
"followers": paginated.page(request.GET.get("page", 1)),
|
||||||
}
|
}
|
||||||
return TemplateResponse(request, "user/followers.html", data)
|
return TemplateResponse(request, "user/followers.html", data)
|
||||||
|
|
||||||
|
@ -131,10 +132,11 @@ class Following(View):
|
||||||
if is_api_request(request):
|
if is_api_request(request):
|
||||||
return ActivitypubResponse(user.to_following_activity(**request.GET))
|
return ActivitypubResponse(user.to_following_activity(**request.GET))
|
||||||
|
|
||||||
|
paginated = Paginator(user.followers.all(), PAGE_LENGTH)
|
||||||
data = {
|
data = {
|
||||||
"user": user,
|
"user": user,
|
||||||
"is_self": request.user.id == user.id,
|
"is_self": request.user.id == user.id,
|
||||||
"following": user.following.all(),
|
"following": paginated.page(request.GET.get("page", 1)),
|
||||||
}
|
}
|
||||||
return TemplateResponse(request, "user/following.html", data)
|
return TemplateResponse(request, "user/following.html", data)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue