revert: issues endpoint (#2555)

This commit is contained in:
Nikhil 2023-10-30 15:05:25 +05:30 committed by GitHub
parent 8cc61bc427
commit 7edaa49c21
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 17 additions and 32 deletions

View File

@ -579,7 +579,6 @@ class CycleIssueViewSet(BaseViewSet):
)
)
total_issues = issues.count()
issues_data = IssueStateSerializer(issues, many=True).data
if sub_group_by and sub_group_by == group_by:
@ -591,12 +590,12 @@ class CycleIssueViewSet(BaseViewSet):
if group_by:
grouped_results = group_results(issues_data, group_by, sub_group_by)
return Response(
{"data": grouped_results, "total_issues": total_issues},
grouped_results,
status=status.HTTP_200_OK,
)
return Response(
{"data": issues_data, "total_issues": total_issues}, status=status.HTTP_200_OK
issues_data, status=status.HTTP_200_OK
)
def create(self, request, slug, project_id, cycle_id):

View File

@ -217,7 +217,6 @@ class IssueViewSet(BaseViewSet):
else:
issue_queryset = issue_queryset.order_by(order_by_param)
total_issues = issue_queryset.count()
issues = IssueLiteSerializer(issue_queryset, many=True).data
## Grouping the results
@ -232,12 +231,12 @@ class IssueViewSet(BaseViewSet):
if group_by:
grouped_results = group_results(issues, group_by, sub_group_by)
return Response(
{"data": grouped_results, "total_issues": total_issues},
grouped_results,
status=status.HTTP_200_OK,
)
return Response(
{"data": issues, "total_issues": total_issues}, status=status.HTTP_200_OK
issues, status=status.HTTP_200_OK
)
@ -426,7 +425,6 @@ class UserWorkSpaceIssues(BaseAPIView):
else:
issue_queryset = issue_queryset.order_by(order_by_param)
total_issues = issue_queryset.count()
issues = IssueLiteSerializer(issue_queryset, many=True).data
## Grouping the results
@ -441,12 +439,12 @@ class UserWorkSpaceIssues(BaseAPIView):
if group_by:
grouped_results = group_results(issues, group_by, sub_group_by)
return Response(
{"data": grouped_results, "total_issues": total_issues},
grouped_results,
status=status.HTTP_200_OK,
)
return Response(
{"data": issues, "total_issues": total_issues}, status=status.HTTP_200_OK
issues, status=status.HTTP_200_OK
)
@ -2151,7 +2149,6 @@ class IssueDraftViewSet(BaseViewSet):
else:
issue_queryset = issue_queryset.order_by(order_by_param)
total_issues = issue_queryset.count()
issues = IssueLiteSerializer(issue_queryset, many=True).data
## Grouping the results
@ -2159,12 +2156,12 @@ class IssueDraftViewSet(BaseViewSet):
if group_by:
grouped_results = group_results(issues, group_by)
return Response(
{"data": grouped_results, "total_issues": total_issues},
grouped_results,
status=status.HTTP_200_OK,
)
return Response(
{"data": issues, "total_issues": total_issues}, status=status.HTTP_200_OK
issues, status=status.HTTP_200_OK
)
def create(self, request, slug, project_id):

View File

@ -364,7 +364,6 @@ class ModuleIssueViewSet(BaseViewSet):
.values("count")
)
)
total_issues = issues.count()
issues_data = IssueStateSerializer(issues, many=True).data
if sub_group_by and sub_group_by == group_by:
@ -376,12 +375,12 @@ class ModuleIssueViewSet(BaseViewSet):
if group_by:
grouped_results = group_results(issues_data, group_by, sub_group_by)
return Response(
{"data": grouped_results, "total_issues": total_issues},
grouped_results,
status=status.HTTP_200_OK,
)
return Response(
{"data": issues_data, "total_issues": total_issues}, status=status.HTTP_200_OK
issues_data, status=status.HTTP_200_OK
)
def create(self, request, slug, project_id, module_id):

View File

@ -93,7 +93,6 @@ class GlobalViewIssuesViewSet(BaseViewSet):
)
)
@method_decorator(gzip_page)
def list(self, request, slug):
filters = issue_filters(request.query_params, "GET")
@ -117,9 +116,7 @@ class GlobalViewIssuesViewSet(BaseViewSet):
.values("count")
)
.annotate(
attachment_count=IssueAttachment.objects.filter(
issue=OuterRef("id")
)
attachment_count=IssueAttachment.objects.filter(issue=OuterRef("id"))
.order_by()
.annotate(count=Func(F("id"), function="Count"))
.values("count")
@ -129,9 +126,7 @@ class GlobalViewIssuesViewSet(BaseViewSet):
# Priority Ordering
if order_by_param == "priority" or order_by_param == "-priority":
priority_order = (
priority_order
if order_by_param == "priority"
else priority_order[::-1]
priority_order if order_by_param == "priority" else priority_order[::-1]
)
issue_queryset = issue_queryset.annotate(
priority_order=Case(
@ -183,8 +178,6 @@ class GlobalViewIssuesViewSet(BaseViewSet):
)
else:
issue_queryset = issue_queryset.order_by(order_by_param)
total_issues = issue_queryset.count()
issues = IssueLiteSerializer(issue_queryset, many=True).data
## Grouping the results
@ -195,17 +188,15 @@ class GlobalViewIssuesViewSet(BaseViewSet):
{"error": "Group by and sub group by cannot be same"},
status=status.HTTP_400_BAD_REQUEST,
)
if group_by:
grouped_results = group_results(issues, group_by, sub_group_by)
return Response(
{"data": grouped_results, "total_issues": total_issues},
grouped_results,
status=status.HTTP_200_OK,
)
return Response(
{"data": issues, "total_issues": total_issues}, status=status.HTTP_200_OK
)
return Response(issues, status=status.HTTP_200_OK)
class IssueViewViewSet(BaseViewSet):

View File

@ -1223,7 +1223,6 @@ class WorkspaceUserProfileIssuesEndpoint(BaseAPIView):
else:
issue_queryset = issue_queryset.order_by(order_by_param)
total_issues = issue_queryset.count()
issues = IssueLiteSerializer(issue_queryset, many=True).data
## Grouping the results
@ -1231,12 +1230,12 @@ class WorkspaceUserProfileIssuesEndpoint(BaseAPIView):
if group_by:
grouped_results = group_results(issues, group_by)
return Response(
{"data": grouped_results, "total_issues": total_issues},
grouped_results,
status=status.HTTP_200_OK,
)
return Response(
{"data": issues, "total_issues": total_issues}, status=status.HTTP_200_OK
issues, status=status.HTTP_200_OK
)