Remove superfluous calls to all()

This commit is contained in:
Mouse Reeve 2021-04-19 14:47:59 -07:00
parent d69ce8cbbd
commit 77775d9bf8
7 changed files with 7 additions and 8 deletions

View file

@ -47,7 +47,7 @@ class List(OrderedCollectionMixin, BookWyrmModel):
@property
def collection_queryset(self):
""" list of books for this shelf, overrides OrderedCollectionMixin """
return self.books.filter(listitem__approved=True).all().order_by("listitem")
return self.books.filter(listitem__approved=True).order_by("listitem")
class Meta:
""" default sorting """

View file

@ -48,7 +48,7 @@ class Shelf(OrderedCollectionMixin, BookWyrmModel):
@property
def collection_queryset(self):
""" list of books for this shelf, overrides OrderedCollectionMixin """
return self.books.all().order_by("shelfbook")
return self.books.order_by("shelfbook")
def get_remote_id(self):
""" shelf identifier instead of id """

View file

@ -67,8 +67,7 @@ def get_replies(status):
reply_parent=status,
deleted=False,
)
.select_subclasses()
.all()[:10]
.select_subclasses()[:10]
)

View file

@ -174,7 +174,7 @@ def get_suggested_books(user, max_books=5):
)
shelf = user.shelf_set.get(identifier=preset)
shelf_books = shelf.shelfbook_set.order_by("-updated_date").all()[:limit]
shelf_books = shelf.shelfbook_set.order_by("-updated_date")[:limit]
if not shelf_books:
continue
shelf_preview = {

View file

@ -75,7 +75,7 @@ class UserLists(View):
except ValueError:
page = 1
user = get_user_from_username(request.user, username)
lists = models.List.objects.filter(user=user).all()
lists = models.List.objects.filter(user=user)
lists = privacy_filter(request.user, lists)
paginated = Paginator(lists, 12)

View file

@ -61,7 +61,7 @@ class Shelf(View):
return ActivitypubResponse(shelf.to_activity(**request.GET))
paginated = Paginator(
shelf.books.order_by("-updated_date").all(),
shelf.books.order_by("-updated_date"),
PAGE_LENGTH,
)

View file

@ -64,7 +64,7 @@ class User(View):
{
"name": user_shelf.name,
"local_path": user_shelf.local_path,
"books": user_shelf.books.all()[:3],
"books": user_shelf.books[:3],
"size": user_shelf.books.count(),
}
)