dev: sub grouping paginator

This commit is contained in:
pablohashescobar 2024-03-15 12:31:31 +05:30
parent d90845b260
commit 981ac13812
7 changed files with 610 additions and 216 deletions

View File

@ -60,7 +60,10 @@ from plane.utils.grouper import (
) )
from plane.utils.issue_filters import issue_filters from plane.utils.issue_filters import issue_filters
from plane.utils.order_queryset import order_issue_queryset from plane.utils.order_queryset import order_issue_queryset
from plane.utils.paginator import GroupedOffsetPaginator from plane.utils.paginator import (
GroupedOffsetPaginator,
SubGroupedOffsetPaginator,
)
# Module imports # Module imports
from .. import BaseAPIView, BaseViewSet, WebhookMixin from .. import BaseAPIView, BaseViewSet, WebhookMixin
@ -781,7 +784,10 @@ class CycleIssueViewSet(WebhookMixin, BaseViewSet):
.values("count") .values("count")
) )
) )
filters = issue_filters(request.query_params, "GET")
order_by_param = request.GET.get("order_by", "-created_at")
issue_queryset = issue_queryset.filter(**filters)
# Issue queryset # Issue queryset
issue_queryset = order_issue_queryset( issue_queryset = order_issue_queryset(
issue_queryset=issue_queryset, issue_queryset=issue_queryset,
@ -790,45 +796,97 @@ class CycleIssueViewSet(WebhookMixin, BaseViewSet):
# Group by # Group by
group_by = request.GET.get("group_by", False) group_by = request.GET.get("group_by", False)
sub_group_by = request.GET.get("sub_group_by", False)
# issue queryset
issue_queryset = issue_queryset_grouper( issue_queryset = issue_queryset_grouper(
queryset=issue_queryset, queryset=issue_queryset,
field=group_by, group_by=group_by,
sub_group_by=sub_group_by,
) )
# List Paginate if group_by:
if not group_by: # Check group and sub group value paginate
return self.paginate( if sub_group_by:
order_by=order_by_param, if group_by == sub_group_by:
request=request, return Response(
queryset=issue_queryset, {
on_results=lambda issues: issue_on_results( "error": "Group by and sub group by cannot have same parameters"
group_by=group_by, issues=issues },
), status=status.HTTP_400_BAD_REQUEST,
) )
else:
# Group paginate # group and sub group pagination
return self.paginate( return self.paginate(
order_by=order_by_param,
request=request, request=request,
order_by=order_by_param,
queryset=issue_queryset, queryset=issue_queryset,
on_results=lambda issues: issue_on_results( on_results=lambda issues: issue_on_results(
group_by=group_by, issues=issues group_by=group_by,
issues=issues,
sub_group_by=sub_group_by,
), ),
paginator_cls=GroupedOffsetPaginator, paginator_cls=SubGroupedOffsetPaginator,
group_by_field_name=group_by,
group_by_fields=issue_group_values( group_by_fields=issue_group_values(
field=group_by, field=group_by,
slug=slug, slug=slug,
project_id=project_id, project_id=project_id,
filters=filters, filters=filters,
), ),
sub_group_by_fields=issue_group_values(
field=sub_group_by,
slug=slug,
project_id=project_id,
filters=filters,
),
group_by_field_name=group_by,
sub_group_by_field_name=sub_group_by,
count_filter=Q( count_filter=Q(
Q(issue_inbox__status=1) Q(issue_inbox__status=1)
| Q(issue_inbox__status=-1) | Q(issue_inbox__status=-1)
| Q(issue_inbox__status=2) | Q(issue_inbox__status=2)
| Q(issue_inbox__isnull=True), | Q(issue_inbox__isnull=True),
archived_at__isnull=False, archived_at__isnull=True,
is_draft=True, is_draft=False,
),
)
# Group Paginate
else:
# Group paginate
return self.paginate(
request=request,
order_by=order_by_param,
queryset=issue_queryset,
on_results=lambda issues: issue_on_results(
group_by=group_by,
issues=issues,
sub_group_by=sub_group_by,
),
paginator_cls=GroupedOffsetPaginator,
group_by_fields=issue_group_values(
field=group_by,
slug=slug,
project_id=project_id,
filters=filters,
),
group_by_field_name=group_by,
count_filter=Q(
Q(issue_inbox__status=1)
| Q(issue_inbox__status=-1)
| Q(issue_inbox__status=2)
| Q(issue_inbox__isnull=True),
archived_at__isnull=True,
is_draft=False,
),
)
else:
# List Paginate
return self.paginate(
order_by=order_by_param,
request=request,
queryset=issue_queryset,
on_results=lambda issues: issue_on_results(
group_by=group_by, issues=issues, sub_group_by=sub_group_by
), ),
) )

View File

@ -43,7 +43,10 @@ from plane.utils.grouper import (
) )
from plane.utils.issue_filters import issue_filters from plane.utils.issue_filters import issue_filters
from plane.utils.order_queryset import order_issue_queryset from plane.utils.order_queryset import order_issue_queryset
from plane.utils.paginator import GroupedOffsetPaginator from plane.utils.paginator import (
GroupedOffsetPaginator,
SubGroupedOffsetPaginator,
)
# Module imports # Module imports
from .. import BaseViewSet from .. import BaseViewSet
@ -116,46 +119,97 @@ class IssueArchiveViewSet(BaseViewSet):
# Group by # Group by
group_by = request.GET.get("group_by", False) group_by = request.GET.get("group_by", False)
sub_group_by = request.GET.get("sub_group_by", False)
# issue queryset
issue_queryset = issue_queryset_grouper( issue_queryset = issue_queryset_grouper(
queryset=issue_queryset, queryset=issue_queryset,
field=group_by, group_by=group_by,
sub_group_by=sub_group_by,
) )
# List Paginate if group_by:
if not group_by: # Check group and sub group value paginate
return self.paginate( if sub_group_by:
order_by=order_by_param, if group_by == sub_group_by:
request=request, return Response(
queryset=issue_queryset, {
on_results=lambda issues: issue_on_results( "error": "Group by and sub group by cannot have same parameters"
group_by=group_by, issues=issues },
), status=status.HTTP_400_BAD_REQUEST,
) )
else:
# Group paginate # group and sub group pagination
return self.paginate( return self.paginate(
order_by=order_by_param,
request=request, request=request,
order_by=order_by_param,
queryset=issue_queryset, queryset=issue_queryset,
on_results=lambda issues: issue_on_results( on_results=lambda issues: issue_on_results(
group_by=group_by, issues=issues group_by=group_by,
issues=issues,
sub_group_by=sub_group_by,
), ),
paginator_cls=GroupedOffsetPaginator, paginator_cls=SubGroupedOffsetPaginator,
group_by_field_name=group_by,
group_by_fields=issue_group_values( group_by_fields=issue_group_values(
field=group_by, field=group_by,
slug=slug, slug=slug,
project_id=project_id, project_id=project_id,
filters=filters, filters=filters,
), ),
sub_group_by_fields=issue_group_values(
field=sub_group_by,
slug=slug,
project_id=project_id,
filters=filters,
),
group_by_field_name=group_by,
sub_group_by_field_name=sub_group_by,
count_filter=Q( count_filter=Q(
Q(issue_inbox__status=1) Q(issue_inbox__status=1)
| Q(issue_inbox__status=-1) | Q(issue_inbox__status=-1)
| Q(issue_inbox__status=2) | Q(issue_inbox__status=2)
| Q(issue_inbox__isnull=True), | Q(issue_inbox__isnull=True),
archived_at__isnull=False, archived_at__isnull=True,
is_draft=True, is_draft=False,
),
)
# Group Paginate
else:
# Group paginate
return self.paginate(
request=request,
order_by=order_by_param,
queryset=issue_queryset,
on_results=lambda issues: issue_on_results(
group_by=group_by,
issues=issues,
sub_group_by=sub_group_by,
),
paginator_cls=GroupedOffsetPaginator,
group_by_fields=issue_group_values(
field=group_by,
slug=slug,
project_id=project_id,
filters=filters,
),
group_by_field_name=group_by,
count_filter=Q(
Q(issue_inbox__status=1)
| Q(issue_inbox__status=-1)
| Q(issue_inbox__status=2)
| Q(issue_inbox__isnull=True),
archived_at__isnull=True,
is_draft=False,
),
)
else:
# List Paginate
return self.paginate(
order_by=order_by_param,
request=request,
queryset=issue_queryset,
on_results=lambda issues: issue_on_results(
group_by=group_by, issues=issues, sub_group_by=sub_group_by
), ),
) )

View File

@ -119,44 +119,97 @@ class IssueListEndpoint(BaseAPIView):
# Group by # Group by
group_by = request.GET.get("group_by", False) group_by = request.GET.get("group_by", False)
sub_group_by = request.GET.get("sub_group_by", False)
# issue queryset
issue_queryset = issue_queryset_grouper( issue_queryset = issue_queryset_grouper(
queryset=issue_queryset, field=group_by queryset=issue_queryset,
group_by=group_by,
sub_group_by=sub_group_by,
) )
# List Paginate if group_by:
if not group_by: # Check group and sub group value paginate
return self.paginate( if sub_group_by:
order_by=order_by_param, if group_by == sub_group_by:
request=request, return Response(
queryset=issue_queryset, {
on_results=lambda issues: issue_on_results( "error": "Group by and sub group by cannot have same parameters"
group_by=group_by, issues=issues },
), status=status.HTTP_400_BAD_REQUEST,
) )
else:
# Group paginate # group and sub group pagination
return self.paginate( return self.paginate(
order_by=order_by_param,
request=request, request=request,
order_by=order_by_param,
queryset=issue_queryset, queryset=issue_queryset,
on_results=lambda issues: issue_on_results( on_results=lambda issues: issue_on_results(
group_by=group_by, issues=issues group_by=group_by,
issues=issues,
sub_group_by=sub_group_by,
), ),
paginator_cls=GroupedOffsetPaginator, paginator_cls=SubGroupedOffsetPaginator,
group_by_field_name=group_by,
group_by_fields=issue_group_values( group_by_fields=issue_group_values(
field=group_by, field=group_by,
slug=slug, slug=slug,
project_id=project_id, project_id=project_id,
filters=filters, filters=filters,
), ),
sub_group_by_fields=issue_group_values(
field=sub_group_by,
slug=slug,
project_id=project_id,
filters=filters,
),
group_by_field_name=group_by,
sub_group_by_field_name=sub_group_by,
count_filter=Q( count_filter=Q(
Q(issue_inbox__status=1) Q(issue_inbox__status=1)
| Q(issue_inbox__status=-1) | Q(issue_inbox__status=-1)
| Q(issue_inbox__status=2) | Q(issue_inbox__status=2)
| Q(issue_inbox__isnull=True), | Q(issue_inbox__isnull=True),
archived_at__isnull=False, archived_at__isnull=True,
is_draft=True, is_draft=False,
),
)
# Group Paginate
else:
# Group paginate
return self.paginate(
request=request,
order_by=order_by_param,
queryset=issue_queryset,
on_results=lambda issues: issue_on_results(
group_by=group_by,
issues=issues,
sub_group_by=sub_group_by,
),
paginator_cls=GroupedOffsetPaginator,
group_by_fields=issue_group_values(
field=group_by,
slug=slug,
project_id=project_id,
filters=filters,
),
group_by_field_name=group_by,
count_filter=Q(
Q(issue_inbox__status=1)
| Q(issue_inbox__status=-1)
| Q(issue_inbox__status=2)
| Q(issue_inbox__isnull=True),
archived_at__isnull=True,
is_draft=False,
),
)
else:
# List Paginate
return self.paginate(
order_by=order_by_param,
request=request,
queryset=issue_queryset,
on_results=lambda issues: issue_on_results(
group_by=group_by, issues=issues, sub_group_by=sub_group_by
), ),
) )

View File

@ -43,7 +43,10 @@ from plane.utils.grouper import (
) )
from plane.utils.issue_filters import issue_filters from plane.utils.issue_filters import issue_filters
from plane.utils.order_queryset import order_issue_queryset from plane.utils.order_queryset import order_issue_queryset
from plane.utils.paginator import GroupedOffsetPaginator from plane.utils.paginator import (
GroupedOffsetPaginator,
SubGroupedOffsetPaginator,
)
# Module imports # Module imports
from .. import BaseViewSet from .. import BaseViewSet
@ -95,7 +98,6 @@ class IssueDraftViewSet(BaseViewSet):
order_by_param = request.GET.get("order_by", "-created_at") order_by_param = request.GET.get("order_by", "-created_at")
issue_queryset = self.get_queryset().filter(**filters) issue_queryset = self.get_queryset().filter(**filters)
# Issue queryset # Issue queryset
issue_queryset = order_issue_queryset( issue_queryset = order_issue_queryset(
issue_queryset=issue_queryset, issue_queryset=issue_queryset,
@ -104,29 +106,71 @@ class IssueDraftViewSet(BaseViewSet):
# Group by # Group by
group_by = request.GET.get("group_by", False) group_by = request.GET.get("group_by", False)
sub_group_by = request.GET.get("sub_group_by", False)
# issue queryset
issue_queryset = issue_queryset_grouper( issue_queryset = issue_queryset_grouper(
queryset=issue_queryset, field=group_by queryset=issue_queryset,
group_by=group_by,
sub_group_by=sub_group_by,
) )
# List Paginate if group_by:
if not group_by: # Check group and sub group value paginate
if sub_group_by:
if group_by == sub_group_by:
return Response(
{
"error": "Group by and sub group by cannot have same parameters"
},
status=status.HTTP_400_BAD_REQUEST,
)
else:
# group and sub group pagination
return self.paginate( return self.paginate(
order_by=order_by_param,
request=request, request=request,
order_by=order_by_param,
queryset=issue_queryset, queryset=issue_queryset,
on_results=lambda issues: issue_on_results( on_results=lambda issues: issue_on_results(
group_by=group_by, issues=issues group_by=group_by,
issues=issues,
sub_group_by=sub_group_by,
),
paginator_cls=SubGroupedOffsetPaginator,
group_by_fields=issue_group_values(
field=group_by,
slug=slug,
project_id=project_id,
filters=filters,
),
sub_group_by_fields=issue_group_values(
field=sub_group_by,
slug=slug,
project_id=project_id,
filters=filters,
),
group_by_field_name=group_by,
sub_group_by_field_name=sub_group_by,
count_filter=Q(
Q(issue_inbox__status=1)
| Q(issue_inbox__status=-1)
| Q(issue_inbox__status=2)
| Q(issue_inbox__isnull=True),
archived_at__isnull=True,
is_draft=False,
), ),
) )
# Group Paginate
else:
# Group paginate # Group paginate
return self.paginate( return self.paginate(
order_by=order_by_param,
request=request, request=request,
order_by=order_by_param,
queryset=issue_queryset, queryset=issue_queryset,
on_results=lambda issues: issue_on_results( on_results=lambda issues: issue_on_results(
group_by=group_by, issues=issues group_by=group_by,
issues=issues,
sub_group_by=sub_group_by,
), ),
paginator_cls=GroupedOffsetPaginator, paginator_cls=GroupedOffsetPaginator,
group_by_fields=issue_group_values( group_by_fields=issue_group_values(
@ -141,8 +185,18 @@ class IssueDraftViewSet(BaseViewSet):
| Q(issue_inbox__status=-1) | Q(issue_inbox__status=-1)
| Q(issue_inbox__status=2) | Q(issue_inbox__status=2)
| Q(issue_inbox__isnull=True), | Q(issue_inbox__isnull=True),
archived_at__isnull=False, archived_at__isnull=True,
is_draft=True, is_draft=False,
),
)
else:
# List Paginate
return self.paginate(
order_by=order_by_param,
request=request,
queryset=issue_queryset,
on_results=lambda issues: issue_on_results(
group_by=group_by, issues=issues, sub_group_by=sub_group_by
), ),
) )

View File

@ -58,7 +58,10 @@ from plane.utils.grouper import (
) )
from plane.utils.issue_filters import issue_filters from plane.utils.issue_filters import issue_filters
from plane.utils.order_queryset import order_issue_queryset from plane.utils.order_queryset import order_issue_queryset
from plane.utils.paginator import GroupedOffsetPaginator from plane.utils.paginator import (
GroupedOffsetPaginator,
SubGroupedOffsetPaginator,
)
# Module imports # Module imports
from .. import BaseAPIView, BaseViewSet, WebhookMixin from .. import BaseAPIView, BaseViewSet, WebhookMixin
@ -517,44 +520,97 @@ class ModuleIssueViewSet(WebhookMixin, BaseViewSet):
# Group by # Group by
group_by = request.GET.get("group_by", False) group_by = request.GET.get("group_by", False)
sub_group_by = request.GET.get("sub_group_by", False)
# issue queryset
issue_queryset = issue_queryset_grouper( issue_queryset = issue_queryset_grouper(
queryset=issue_queryset, field=group_by queryset=issue_queryset,
group_by=group_by,
sub_group_by=sub_group_by,
) )
# List Paginate if group_by:
if not group_by: # Check group and sub group value paginate
return self.paginate( if sub_group_by:
order_by=order_by_param, if group_by == sub_group_by:
request=request, return Response(
queryset=issue_queryset, {
on_results=lambda issues: issue_on_results( "error": "Group by and sub group by cannot have same parameters"
group_by=group_by, issues=issues },
), status=status.HTTP_400_BAD_REQUEST,
) )
else:
# Group paginate # group and sub group pagination
return self.paginate( return self.paginate(
order_by=order_by_param,
request=request, request=request,
order_by=order_by_param,
queryset=issue_queryset, queryset=issue_queryset,
on_results=lambda issues: issue_on_results( on_results=lambda issues: issue_on_results(
group_by=group_by, issues=issues group_by=group_by,
issues=issues,
sub_group_by=sub_group_by,
), ),
paginator_cls=SubGroupedOffsetPaginator,
group_by_fields=issue_group_values( group_by_fields=issue_group_values(
field=group_by, field=group_by,
slug=slug, slug=slug,
project_id=project_id, project_id=project_id,
filters=filters, filters=filters,
), ),
sub_group_by_fields=issue_group_values(
field=sub_group_by,
slug=slug,
project_id=project_id,
filters=filters,
),
group_by_field_name=group_by,
sub_group_by_field_name=sub_group_by,
count_filter=Q(
Q(issue_inbox__status=1)
| Q(issue_inbox__status=-1)
| Q(issue_inbox__status=2)
| Q(issue_inbox__isnull=True),
archived_at__isnull=True,
is_draft=False,
),
)
# Group Paginate
else:
# Group paginate
return self.paginate(
request=request,
order_by=order_by_param,
queryset=issue_queryset,
on_results=lambda issues: issue_on_results(
group_by=group_by,
issues=issues,
sub_group_by=sub_group_by,
),
paginator_cls=GroupedOffsetPaginator, paginator_cls=GroupedOffsetPaginator,
group_by_fields=issue_group_values(
field=group_by,
slug=slug,
project_id=project_id,
filters=filters,
),
group_by_field_name=group_by, group_by_field_name=group_by,
count_filter=Q( count_filter=Q(
Q(issue_inbox__status=1) Q(issue_inbox__status=1)
| Q(issue_inbox__status=-1) | Q(issue_inbox__status=-1)
| Q(issue_inbox__status=2) | Q(issue_inbox__status=2)
| Q(issue_inbox__isnull=True), | Q(issue_inbox__isnull=True),
archived_at__isnull=False, archived_at__isnull=True,
is_draft=True, is_draft=False,
),
)
else:
# List Paginate
return self.paginate(
order_by=order_by_param,
request=request,
queryset=issue_queryset,
on_results=lambda issues: issue_on_results(
group_by=group_by, issues=issues, sub_group_by=sub_group_by
), ),
) )

View File

@ -41,7 +41,10 @@ from plane.utils.grouper import (
) )
from plane.utils.issue_filters import issue_filters from plane.utils.issue_filters import issue_filters
from plane.utils.order_queryset import order_issue_queryset from plane.utils.order_queryset import order_issue_queryset
from plane.utils.paginator import GroupedOffsetPaginator from plane.utils.paginator import (
GroupedOffsetPaginator,
SubGroupedOffsetPaginator,
)
# Module imports # Module imports
from .. import BaseViewSet from .. import BaseViewSet
@ -153,49 +156,106 @@ class GlobalViewIssuesViewSet(BaseViewSet):
.filter(**filters) .filter(**filters)
.annotate(cycle_id=F("issue_cycle__cycle_id")) .annotate(cycle_id=F("issue_cycle__cycle_id"))
) )
# Issue queryset
issue_queryset = order_issue_queryset( issue_queryset = order_issue_queryset(
issue_queryset=issue_queryset, order_by_param=order_by_param issue_queryset=issue_queryset,
order_by_param=order_by_param,
) )
# Group by # Group by
group_by = request.GET.get("group_by", False) group_by = request.GET.get("group_by", False)
sub_group_by = request.GET.get("sub_group_by", False)
# issue queryset
issue_queryset = issue_queryset_grouper( issue_queryset = issue_queryset_grouper(
queryset=issue_queryset, field=group_by queryset=issue_queryset,
group_by=group_by,
sub_group_by=sub_group_by,
) )
# List Paginate if group_by:
if not group_by: # Check group and sub group value paginate
return self.paginate( if sub_group_by:
order_by=request.GET.get("order_by", "-created_at"), if group_by == sub_group_by:
request=request, return Response(
queryset=issue_queryset, {
on_results=lambda issues: issue_on_results( "error": "Group by and sub group by cannot have same parameters"
group_by=group_by, issues=issues },
), status=status.HTTP_400_BAD_REQUEST,
) )
else:
# Group paginate # group and sub group pagination
return self.paginate( return self.paginate(
order_by=request.GET.get("order_by", "-created_at"),
request=request, request=request,
order_by=order_by_param,
queryset=issue_queryset, queryset=issue_queryset,
on_results=lambda issues: issue_on_results( on_results=lambda issues: issue_on_results(
group_by=group_by, issues=issues group_by=group_by,
issues=issues,
sub_group_by=sub_group_by,
), ),
paginator_cls=SubGroupedOffsetPaginator,
group_by_fields=issue_group_values( group_by_fields=issue_group_values(
field=group_by, field=group_by,
slug=slug, slug=slug,
project_id=None,
filters=filters, filters=filters,
), ),
sub_group_by_fields=issue_group_values(
field=sub_group_by,
slug=slug,
project_id=None,
filters=filters,
),
group_by_field_name=group_by,
sub_group_by_field_name=sub_group_by,
count_filter=Q(
Q(issue_inbox__status=1)
| Q(issue_inbox__status=-1)
| Q(issue_inbox__status=2)
| Q(issue_inbox__isnull=True),
archived_at__isnull=True,
is_draft=False,
),
)
# Group Paginate
else:
# Group paginate
return self.paginate(
request=request,
order_by=order_by_param,
queryset=issue_queryset,
on_results=lambda issues: issue_on_results(
group_by=group_by,
issues=issues,
sub_group_by=sub_group_by,
),
paginator_cls=GroupedOffsetPaginator, paginator_cls=GroupedOffsetPaginator,
group_by_fields=issue_group_values(
field=group_by,
slug=slug,
project_id=None,
filters=filters,
),
group_by_field_name=group_by, group_by_field_name=group_by,
count_filter=Q( count_filter=Q(
Q(issue_inbox__status=1) Q(issue_inbox__status=1)
| Q(issue_inbox__status=-1) | Q(issue_inbox__status=-1)
| Q(issue_inbox__status=2) | Q(issue_inbox__status=2)
| Q(issue_inbox__isnull=True), | Q(issue_inbox__isnull=True),
archived_at__isnull=False, archived_at__isnull=True,
is_draft=True, is_draft=False,
),
)
else:
# List Paginate
return self.paginate(
order_by=order_by_param,
request=request,
queryset=issue_queryset,
on_results=lambda issues: issue_on_results(
group_by=group_by, issues=issues, sub_group_by=sub_group_by
), ),
) )

View File

@ -45,7 +45,10 @@ from plane.utils.grouper import (
) )
from plane.utils.issue_filters import issue_filters from plane.utils.issue_filters import issue_filters
from plane.utils.order_queryset import order_issue_queryset from plane.utils.order_queryset import order_issue_queryset
from plane.utils.paginator import GroupedOffsetPaginator from plane.utils.paginator import (
GroupedOffsetPaginator,
SubGroupedOffsetPaginator,
)
# Module imports # Module imports
from .base import BaseAPIView, BaseViewSet from .base import BaseAPIView, BaseViewSet
@ -566,31 +569,77 @@ class ProjectIssuesPublicEndpoint(BaseAPIView):
# Group by # Group by
group_by = request.GET.get("group_by", False) group_by = request.GET.get("group_by", False)
sub_group_by = request.GET.get("sub_group_by", False)
# issue queryset
issue_queryset = issue_queryset_grouper( issue_queryset = issue_queryset_grouper(
queryset=issue_queryset, field=group_by queryset=issue_queryset,
group_by=group_by,
sub_group_by=sub_group_by,
) )
# List Paginate if group_by:
if not group_by: # Check group and sub group value paginate
if sub_group_by:
if group_by == sub_group_by:
return Response(
{
"error": "Group by and sub group by cannot have same parameters"
},
status=status.HTTP_400_BAD_REQUEST,
)
else:
# group and sub group pagination
return self.paginate( return self.paginate(
request=request, request=request,
order_by=order_by_param,
queryset=issue_queryset, queryset=issue_queryset,
on_results=lambda issues: issue_on_results( on_results=lambda issues: issue_on_results(
group_by=group_by, issues=issues group_by=group_by,
issues=issues,
sub_group_by=sub_group_by,
),
paginator_cls=SubGroupedOffsetPaginator,
group_by_fields=issue_group_values(
field=group_by,
slug=slug,
project_id=project_id,
filters=filters,
),
sub_group_by_fields=issue_group_values(
field=sub_group_by,
slug=slug,
project_id=project_id,
filters=filters,
),
group_by_field_name=group_by,
sub_group_by_field_name=sub_group_by,
count_filter=Q(
Q(issue_inbox__status=1)
| Q(issue_inbox__status=-1)
| Q(issue_inbox__status=2)
| Q(issue_inbox__isnull=True),
archived_at__isnull=True,
is_draft=False,
), ),
) )
# Group Paginate
else:
# Group paginate # Group paginate
return self.paginate( return self.paginate(
request=request, request=request,
order_by=order_by_param,
queryset=issue_queryset, queryset=issue_queryset,
on_results=lambda issues: issue_on_results( on_results=lambda issues: issue_on_results(
group_by=group_by, issues=issues group_by=group_by,
issues=issues,
sub_group_by=sub_group_by,
), ),
paginator_cls=GroupedOffsetPaginator, paginator_cls=GroupedOffsetPaginator,
group_by_fields=issue_group_values( group_by_fields=issue_group_values(
field=group_by, field=group_by,
slug=slug, slug=slug,
project_id=project_id,
filters=filters, filters=filters,
), ),
group_by_field_name=group_by, group_by_field_name=group_by,
@ -599,7 +648,17 @@ class ProjectIssuesPublicEndpoint(BaseAPIView):
| Q(issue_inbox__status=-1) | Q(issue_inbox__status=-1)
| Q(issue_inbox__status=2) | Q(issue_inbox__status=2)
| Q(issue_inbox__isnull=True), | Q(issue_inbox__isnull=True),
archived_at__isnull=False, archived_at__isnull=True,
is_draft=True, is_draft=False,
),
)
else:
# List Paginate
return self.paginate(
order_by=order_by_param,
request=request,
queryset=issue_queryset,
on_results=lambda issues: issue_on_results(
group_by=group_by, issues=issues, sub_group_by=sub_group_by
), ),
) )