mirror of
https://github.com/makeplane/plane
synced 2024-06-14 14:31:34 +00:00
dev: fix order by for pagination
This commit is contained in:
parent
b4416b9172
commit
3f19326c2c
@ -890,7 +890,11 @@ class CycleIssueViewSet(WebhookMixin, BaseViewSet):
|
|||||||
else:
|
else:
|
||||||
# List Paginate
|
# List Paginate
|
||||||
return self.paginate(
|
return self.paginate(
|
||||||
order_by=order_by_param,
|
order_by=(
|
||||||
|
"-priority_order"
|
||||||
|
if order_by_param in ["priority", "-priority"]
|
||||||
|
else order_by_param
|
||||||
|
),
|
||||||
request=request,
|
request=request,
|
||||||
queryset=issue_queryset,
|
queryset=issue_queryset,
|
||||||
on_results=lambda issues: issue_on_results(
|
on_results=lambda issues: issue_on_results(
|
||||||
|
@ -213,7 +213,11 @@ class IssueArchiveViewSet(BaseViewSet):
|
|||||||
else:
|
else:
|
||||||
# List Paginate
|
# List Paginate
|
||||||
return self.paginate(
|
return self.paginate(
|
||||||
order_by=order_by_param,
|
order_by=(
|
||||||
|
"-priority_order"
|
||||||
|
if order_by_param in ["priority", "-priority"]
|
||||||
|
else order_by_param
|
||||||
|
),
|
||||||
request=request,
|
request=request,
|
||||||
queryset=issue_queryset,
|
queryset=issue_queryset,
|
||||||
on_results=lambda issues: issue_on_results(
|
on_results=lambda issues: issue_on_results(
|
||||||
|
@ -213,7 +213,11 @@ class IssueListEndpoint(BaseAPIView):
|
|||||||
else:
|
else:
|
||||||
# List Paginate
|
# List Paginate
|
||||||
return self.paginate(
|
return self.paginate(
|
||||||
order_by=order_by_param,
|
order_by=(
|
||||||
|
"-priority_order"
|
||||||
|
if order_by_param in ["priority", "-priority"]
|
||||||
|
else order_by_param
|
||||||
|
),
|
||||||
request=request,
|
request=request,
|
||||||
queryset=issue_queryset,
|
queryset=issue_queryset,
|
||||||
on_results=lambda issues: issue_on_results(
|
on_results=lambda issues: issue_on_results(
|
||||||
|
@ -200,7 +200,11 @@ class IssueDraftViewSet(BaseViewSet):
|
|||||||
else:
|
else:
|
||||||
# List Paginate
|
# List Paginate
|
||||||
return self.paginate(
|
return self.paginate(
|
||||||
order_by=order_by_param,
|
order_by=(
|
||||||
|
"-priority_order"
|
||||||
|
if order_by_param in ["priority", "-priority"]
|
||||||
|
else order_by_param
|
||||||
|
),
|
||||||
request=request,
|
request=request,
|
||||||
queryset=issue_queryset,
|
queryset=issue_queryset,
|
||||||
on_results=lambda issues: issue_on_results(
|
on_results=lambda issues: issue_on_results(
|
||||||
|
@ -614,7 +614,11 @@ class ModuleIssueViewSet(WebhookMixin, BaseViewSet):
|
|||||||
else:
|
else:
|
||||||
# List Paginate
|
# List Paginate
|
||||||
return self.paginate(
|
return self.paginate(
|
||||||
order_by=order_by_param,
|
order_by=(
|
||||||
|
"-priority_order"
|
||||||
|
if order_by_param in ["priority", "-priority"]
|
||||||
|
else order_by_param
|
||||||
|
),
|
||||||
request=request,
|
request=request,
|
||||||
queryset=issue_queryset,
|
queryset=issue_queryset,
|
||||||
on_results=lambda issues: issue_on_results(
|
on_results=lambda issues: issue_on_results(
|
||||||
|
@ -259,7 +259,11 @@ class GlobalViewIssuesViewSet(BaseViewSet):
|
|||||||
else:
|
else:
|
||||||
# List Paginate
|
# List Paginate
|
||||||
return self.paginate(
|
return self.paginate(
|
||||||
order_by=order_by_param,
|
order_by=(
|
||||||
|
"-priority_order"
|
||||||
|
if order_by_param in ["priority", "-priority"]
|
||||||
|
else order_by_param
|
||||||
|
),
|
||||||
request=request,
|
request=request,
|
||||||
queryset=issue_queryset,
|
queryset=issue_queryset,
|
||||||
on_results=lambda issues: issue_on_results(
|
on_results=lambda issues: issue_on_results(
|
||||||
|
@ -663,7 +663,11 @@ class ProjectIssuesPublicEndpoint(BaseAPIView):
|
|||||||
else:
|
else:
|
||||||
# List Paginate
|
# List Paginate
|
||||||
return self.paginate(
|
return self.paginate(
|
||||||
order_by=order_by_param,
|
order_by=(
|
||||||
|
"-priority_order"
|
||||||
|
if order_by_param in ["priority", "-priority"]
|
||||||
|
else order_by_param
|
||||||
|
),
|
||||||
request=request,
|
request=request,
|
||||||
queryset=issue_queryset,
|
queryset=issue_queryset,
|
||||||
on_results=lambda issues: issue_on_results(
|
on_results=lambda issues: issue_on_results(
|
||||||
|
@ -6,9 +6,9 @@ from collections.abc import Sequence
|
|||||||
# Django imports
|
# Django imports
|
||||||
from django.db.models import Count, F, Window
|
from django.db.models import Count, F, Window
|
||||||
from django.db.models.functions import RowNumber
|
from django.db.models.functions import RowNumber
|
||||||
from rest_framework.exceptions import ParseError
|
|
||||||
|
|
||||||
# Third party imports
|
# Third party imports
|
||||||
|
from rest_framework.exceptions import ParseError
|
||||||
from rest_framework.response import Response
|
from rest_framework.response import Response
|
||||||
|
|
||||||
# Module imports
|
# Module imports
|
||||||
@ -115,7 +115,9 @@ class OffsetPaginator:
|
|||||||
|
|
||||||
queryset = self.queryset
|
queryset = self.queryset
|
||||||
if self.key:
|
if self.key:
|
||||||
queryset = queryset.order_by(*self.key)
|
queryset = queryset.order_by(
|
||||||
|
*self.key,
|
||||||
|
)
|
||||||
|
|
||||||
page = cursor.offset
|
page = cursor.offset
|
||||||
offset = cursor.offset * cursor.value
|
offset = cursor.offset * cursor.value
|
||||||
@ -506,12 +508,6 @@ class SubGroupedOffsetPaginator(OffsetPaginator):
|
|||||||
for group in self.group_by_fields
|
for group in self.group_by_fields
|
||||||
}
|
}
|
||||||
|
|
||||||
def __result_already_added(self, result, group):
|
|
||||||
for existing_issue in group:
|
|
||||||
if existing_issue["id"] == result["id"]:
|
|
||||||
return True
|
|
||||||
return False
|
|
||||||
|
|
||||||
def __query_multi_grouper(self, results):
|
def __query_multi_grouper(self, results):
|
||||||
processed_results = self.__get_field_dict()
|
processed_results = self.__get_field_dict()
|
||||||
# Preparing a dict to keep track of group IDs associated with each label ID
|
# Preparing a dict to keep track of group IDs associated with each label ID
|
||||||
|
Loading…
Reference in New Issue
Block a user