mirror of
https://github.com/makeplane/plane
synced 2024-06-14 14:31:34 +00:00
fix: ordering in queryset (#598)
This commit is contained in:
parent
5aad20e7ed
commit
9c4fcca6c1
@ -94,7 +94,7 @@ class CycleViewSet(BaseViewSet):
|
||||
filter=Q(issue_cycle__issue__state__group="backlog"),
|
||||
)
|
||||
)
|
||||
.order_by("name", "-is_favorite")
|
||||
.order_by("-is_favorite", "name")
|
||||
.distinct()
|
||||
)
|
||||
|
||||
|
@ -104,7 +104,7 @@ class ModuleViewSet(BaseViewSet):
|
||||
filter=Q(issue_module__issue__state__group="backlog"),
|
||||
)
|
||||
)
|
||||
.order_by("name", "-is_favorite")
|
||||
.order_by("-is_favorite", "name")
|
||||
)
|
||||
|
||||
def create(self, request, slug, project_id):
|
||||
|
@ -258,7 +258,7 @@ class RecentPagesEndpoint(BaseAPIView):
|
||||
.select_related("workspace")
|
||||
.select_related("owned_by")
|
||||
.prefetch_related("labels")
|
||||
.order_by("-updated_by")
|
||||
.order_by("-is_favorite", "-updated_by")
|
||||
)
|
||||
|
||||
yesterdays_pages = (
|
||||
@ -274,7 +274,7 @@ class RecentPagesEndpoint(BaseAPIView):
|
||||
.select_related("workspace")
|
||||
.select_related("owned_by")
|
||||
.prefetch_related("labels")
|
||||
.order_by("-updated_by")
|
||||
.order_by("-is_favorite", "-updated_by")
|
||||
)
|
||||
|
||||
earlier_this_week = (
|
||||
@ -294,7 +294,7 @@ class RecentPagesEndpoint(BaseAPIView):
|
||||
.select_related("workspace")
|
||||
.select_related("owned_by")
|
||||
.prefetch_related("labels")
|
||||
.order_by("-updated_by")
|
||||
.order_by("-is_favorite", "-updated_by")
|
||||
)
|
||||
todays_pages_serializer = PageSerializer(todays_pages, many=True)
|
||||
yesterday_pages_serializer = PageSerializer(yesterdays_pages, many=True)
|
||||
@ -378,7 +378,7 @@ class MyPagesEndpoint(BaseAPIView):
|
||||
.annotate(is_favorite=Exists(subquery))
|
||||
.filter(Q(owned_by=self.request.user) | Q(access=0))
|
||||
.filter(project__project_projectmember__member=request.user)
|
||||
.order_by("name", "-is_favorite")
|
||||
.order_by("-is_favorite", "name")
|
||||
)
|
||||
serializer = PageSerializer(pages, many=True)
|
||||
return Response(serializer.data, status=status.HTTP_200_OK)
|
||||
@ -415,7 +415,7 @@ class CreatedbyOtherPagesEndpoint(BaseAPIView):
|
||||
.select_related("owned_by")
|
||||
.prefetch_related("labels")
|
||||
.annotate(is_favorite=Exists(subquery))
|
||||
.order_by("name", "-is_favorite")
|
||||
.order_by("-is_favorite", "name")
|
||||
)
|
||||
serializer = PageSerializer(pages, many=True)
|
||||
return Response(serializer.data, status=status.HTTP_200_OK)
|
||||
|
@ -91,7 +91,7 @@ class ProjectViewSet(BaseViewSet):
|
||||
projects = (
|
||||
self.get_queryset()
|
||||
.annotate(is_favorite=Exists(subquery))
|
||||
.order_by("name", "-is_favorite")
|
||||
.order_by("-is_favorite", "name")
|
||||
)
|
||||
return Response(ProjectDetailSerializer(projects, many=True).data)
|
||||
except Exception as e:
|
||||
|
@ -53,7 +53,7 @@ class IssueViewViewSet(BaseViewSet):
|
||||
.select_related("project")
|
||||
.select_related("workspace")
|
||||
.annotate(is_favorite=Exists(subquery))
|
||||
.order_by("name", "-is_favorite")
|
||||
.order_by("-is_favorite", "name")
|
||||
.distinct()
|
||||
)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user