forked from github/plane
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"),
|
filter=Q(issue_cycle__issue__state__group="backlog"),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
.order_by("name", "-is_favorite")
|
.order_by("-is_favorite", "name")
|
||||||
.distinct()
|
.distinct()
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -104,7 +104,7 @@ class ModuleViewSet(BaseViewSet):
|
|||||||
filter=Q(issue_module__issue__state__group="backlog"),
|
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):
|
def create(self, request, slug, project_id):
|
||||||
|
@ -258,7 +258,7 @@ class RecentPagesEndpoint(BaseAPIView):
|
|||||||
.select_related("workspace")
|
.select_related("workspace")
|
||||||
.select_related("owned_by")
|
.select_related("owned_by")
|
||||||
.prefetch_related("labels")
|
.prefetch_related("labels")
|
||||||
.order_by("-updated_by")
|
.order_by("-is_favorite", "-updated_by")
|
||||||
)
|
)
|
||||||
|
|
||||||
yesterdays_pages = (
|
yesterdays_pages = (
|
||||||
@ -274,7 +274,7 @@ class RecentPagesEndpoint(BaseAPIView):
|
|||||||
.select_related("workspace")
|
.select_related("workspace")
|
||||||
.select_related("owned_by")
|
.select_related("owned_by")
|
||||||
.prefetch_related("labels")
|
.prefetch_related("labels")
|
||||||
.order_by("-updated_by")
|
.order_by("-is_favorite", "-updated_by")
|
||||||
)
|
)
|
||||||
|
|
||||||
earlier_this_week = (
|
earlier_this_week = (
|
||||||
@ -294,7 +294,7 @@ class RecentPagesEndpoint(BaseAPIView):
|
|||||||
.select_related("workspace")
|
.select_related("workspace")
|
||||||
.select_related("owned_by")
|
.select_related("owned_by")
|
||||||
.prefetch_related("labels")
|
.prefetch_related("labels")
|
||||||
.order_by("-updated_by")
|
.order_by("-is_favorite", "-updated_by")
|
||||||
)
|
)
|
||||||
todays_pages_serializer = PageSerializer(todays_pages, many=True)
|
todays_pages_serializer = PageSerializer(todays_pages, many=True)
|
||||||
yesterday_pages_serializer = PageSerializer(yesterdays_pages, many=True)
|
yesterday_pages_serializer = PageSerializer(yesterdays_pages, many=True)
|
||||||
@ -378,7 +378,7 @@ class MyPagesEndpoint(BaseAPIView):
|
|||||||
.annotate(is_favorite=Exists(subquery))
|
.annotate(is_favorite=Exists(subquery))
|
||||||
.filter(Q(owned_by=self.request.user) | Q(access=0))
|
.filter(Q(owned_by=self.request.user) | Q(access=0))
|
||||||
.filter(project__project_projectmember__member=request.user)
|
.filter(project__project_projectmember__member=request.user)
|
||||||
.order_by("name", "-is_favorite")
|
.order_by("-is_favorite", "name")
|
||||||
)
|
)
|
||||||
serializer = PageSerializer(pages, many=True)
|
serializer = PageSerializer(pages, many=True)
|
||||||
return Response(serializer.data, status=status.HTTP_200_OK)
|
return Response(serializer.data, status=status.HTTP_200_OK)
|
||||||
@ -415,7 +415,7 @@ class CreatedbyOtherPagesEndpoint(BaseAPIView):
|
|||||||
.select_related("owned_by")
|
.select_related("owned_by")
|
||||||
.prefetch_related("labels")
|
.prefetch_related("labels")
|
||||||
.annotate(is_favorite=Exists(subquery))
|
.annotate(is_favorite=Exists(subquery))
|
||||||
.order_by("name", "-is_favorite")
|
.order_by("-is_favorite", "name")
|
||||||
)
|
)
|
||||||
serializer = PageSerializer(pages, many=True)
|
serializer = PageSerializer(pages, many=True)
|
||||||
return Response(serializer.data, status=status.HTTP_200_OK)
|
return Response(serializer.data, status=status.HTTP_200_OK)
|
||||||
|
@ -91,7 +91,7 @@ class ProjectViewSet(BaseViewSet):
|
|||||||
projects = (
|
projects = (
|
||||||
self.get_queryset()
|
self.get_queryset()
|
||||||
.annotate(is_favorite=Exists(subquery))
|
.annotate(is_favorite=Exists(subquery))
|
||||||
.order_by("name", "-is_favorite")
|
.order_by("-is_favorite", "name")
|
||||||
)
|
)
|
||||||
return Response(ProjectDetailSerializer(projects, many=True).data)
|
return Response(ProjectDetailSerializer(projects, many=True).data)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
@ -53,7 +53,7 @@ class IssueViewViewSet(BaseViewSet):
|
|||||||
.select_related("project")
|
.select_related("project")
|
||||||
.select_related("workspace")
|
.select_related("workspace")
|
||||||
.annotate(is_favorite=Exists(subquery))
|
.annotate(is_favorite=Exists(subquery))
|
||||||
.order_by("name", "-is_favorite")
|
.order_by("-is_favorite", "name")
|
||||||
.distinct()
|
.distinct()
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user