Remove superfluous calls to `all()`
This commit is contained in:
parent
d69ce8cbbd
commit
77775d9bf8
|
@ -47,7 +47,7 @@ class List(OrderedCollectionMixin, BookWyrmModel):
|
||||||
@property
|
@property
|
||||||
def collection_queryset(self):
|
def collection_queryset(self):
|
||||||
""" list of books for this shelf, overrides OrderedCollectionMixin """
|
""" 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:
|
class Meta:
|
||||||
""" default sorting """
|
""" default sorting """
|
||||||
|
|
|
@ -48,7 +48,7 @@ class Shelf(OrderedCollectionMixin, BookWyrmModel):
|
||||||
@property
|
@property
|
||||||
def collection_queryset(self):
|
def collection_queryset(self):
|
||||||
""" list of books for this shelf, overrides OrderedCollectionMixin """
|
""" 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):
|
def get_remote_id(self):
|
||||||
""" shelf identifier instead of id """
|
""" shelf identifier instead of id """
|
||||||
|
|
|
@ -67,8 +67,7 @@ def get_replies(status):
|
||||||
reply_parent=status,
|
reply_parent=status,
|
||||||
deleted=False,
|
deleted=False,
|
||||||
)
|
)
|
||||||
.select_subclasses()
|
.select_subclasses()[:10]
|
||||||
.all()[:10]
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -174,7 +174,7 @@ def get_suggested_books(user, max_books=5):
|
||||||
)
|
)
|
||||||
shelf = user.shelf_set.get(identifier=preset)
|
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:
|
if not shelf_books:
|
||||||
continue
|
continue
|
||||||
shelf_preview = {
|
shelf_preview = {
|
||||||
|
|
|
@ -75,7 +75,7 @@ class UserLists(View):
|
||||||
except ValueError:
|
except ValueError:
|
||||||
page = 1
|
page = 1
|
||||||
user = get_user_from_username(request.user, username)
|
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)
|
lists = privacy_filter(request.user, lists)
|
||||||
paginated = Paginator(lists, 12)
|
paginated = Paginator(lists, 12)
|
||||||
|
|
||||||
|
|
|
@ -61,7 +61,7 @@ class Shelf(View):
|
||||||
return ActivitypubResponse(shelf.to_activity(**request.GET))
|
return ActivitypubResponse(shelf.to_activity(**request.GET))
|
||||||
|
|
||||||
paginated = Paginator(
|
paginated = Paginator(
|
||||||
shelf.books.order_by("-updated_date").all(),
|
shelf.books.order_by("-updated_date"),
|
||||||
PAGE_LENGTH,
|
PAGE_LENGTH,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -64,7 +64,7 @@ class User(View):
|
||||||
{
|
{
|
||||||
"name": user_shelf.name,
|
"name": user_shelf.name,
|
||||||
"local_path": user_shelf.local_path,
|
"local_path": user_shelf.local_path,
|
||||||
"books": user_shelf.books.all()[:3],
|
"books": user_shelf.books[:3],
|
||||||
"size": user_shelf.books.count(),
|
"size": user_shelf.books.count(),
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue