chore: advance views queryset change (#5182)
This commit is contained in:
parent
b95d7716e2
commit
c6909604b1
3 changed files with 43 additions and 18 deletions
|
|
@ -3,7 +3,6 @@ from django.urls import path
|
||||||
|
|
||||||
from plane.space.views import (
|
from plane.space.views import (
|
||||||
InboxIssuePublicViewSet,
|
InboxIssuePublicViewSet,
|
||||||
IssueVotePublicViewSet,
|
|
||||||
WorkspaceProjectDeployBoardEndpoint,
|
WorkspaceProjectDeployBoardEndpoint,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -30,17 +29,6 @@ urlpatterns = [
|
||||||
),
|
),
|
||||||
name="inbox-issue",
|
name="inbox-issue",
|
||||||
),
|
),
|
||||||
path(
|
|
||||||
"anchor/<str:anchor>/issues/<uuid:issue_id>/votes/",
|
|
||||||
IssueVotePublicViewSet.as_view(
|
|
||||||
{
|
|
||||||
"get": "list",
|
|
||||||
"post": "create",
|
|
||||||
"delete": "destroy",
|
|
||||||
}
|
|
||||||
),
|
|
||||||
name="issue-vote-project-board",
|
|
||||||
),
|
|
||||||
path(
|
path(
|
||||||
"workspaces/<str:slug>/project-boards/",
|
"workspaces/<str:slug>/project-boards/",
|
||||||
WorkspaceProjectDeployBoardEndpoint.as_view(),
|
WorkspaceProjectDeployBoardEndpoint.as_view(),
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ from plane.space.views import (
|
||||||
IssueCommentPublicViewSet,
|
IssueCommentPublicViewSet,
|
||||||
IssueReactionPublicViewSet,
|
IssueReactionPublicViewSet,
|
||||||
CommentReactionPublicViewSet,
|
CommentReactionPublicViewSet,
|
||||||
|
IssueVotePublicViewSet,
|
||||||
)
|
)
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
|
|
@ -73,4 +74,15 @@ urlpatterns = [
|
||||||
),
|
),
|
||||||
name="comment-reactions-project-board",
|
name="comment-reactions-project-board",
|
||||||
),
|
),
|
||||||
|
path(
|
||||||
|
"anchor/<str:anchor>/issues/<uuid:issue_id>/votes/",
|
||||||
|
IssueVotePublicViewSet.as_view(
|
||||||
|
{
|
||||||
|
"get": "list",
|
||||||
|
"post": "create",
|
||||||
|
"delete": "destroy",
|
||||||
|
}
|
||||||
|
),
|
||||||
|
name="issue-vote-project-board",
|
||||||
|
),
|
||||||
]
|
]
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,12 @@
|
||||||
# Python imports
|
# Python imports
|
||||||
import json
|
import json
|
||||||
|
|
||||||
|
# Django imports
|
||||||
from django.contrib.postgres.aggregates import ArrayAgg
|
from django.contrib.postgres.aggregates import ArrayAgg
|
||||||
from django.contrib.postgres.fields import ArrayField
|
from django.contrib.postgres.fields import ArrayField
|
||||||
from django.db.models.functions import Coalesce, JSONObject
|
from django.db.models.functions import Coalesce, JSONObject
|
||||||
from django.core.serializers.json import DjangoJSONEncoder
|
from django.core.serializers.json import DjangoJSONEncoder
|
||||||
|
from django.utils import timezone
|
||||||
from django.db.models import (
|
from django.db.models import (
|
||||||
Exists,
|
Exists,
|
||||||
F,
|
F,
|
||||||
|
|
@ -14,15 +17,15 @@ from django.db.models import (
|
||||||
When,
|
When,
|
||||||
JSONField,
|
JSONField,
|
||||||
Value,
|
Value,
|
||||||
|
OuterRef,
|
||||||
|
Func
|
||||||
)
|
)
|
||||||
|
|
||||||
# Django imports
|
|
||||||
from django.utils import timezone
|
|
||||||
from rest_framework import status
|
|
||||||
from rest_framework.permissions import AllowAny, IsAuthenticated
|
|
||||||
|
|
||||||
# Third Party imports
|
# Third Party imports
|
||||||
from rest_framework.response import Response
|
from rest_framework.response import Response
|
||||||
|
from rest_framework import status
|
||||||
|
from rest_framework.permissions import AllowAny, IsAuthenticated
|
||||||
|
|
||||||
|
|
||||||
# Module imports
|
# Module imports
|
||||||
from .base import BaseAPIView, BaseViewSet
|
from .base import BaseAPIView, BaseViewSet
|
||||||
|
|
@ -43,7 +46,6 @@ from plane.utils.paginator import (
|
||||||
from plane.app.serializers import (
|
from plane.app.serializers import (
|
||||||
CommentReactionSerializer,
|
CommentReactionSerializer,
|
||||||
IssueCommentSerializer,
|
IssueCommentSerializer,
|
||||||
IssuePublicSerializer,
|
|
||||||
IssueReactionSerializer,
|
IssueReactionSerializer,
|
||||||
IssueVoteSerializer,
|
IssueVoteSerializer,
|
||||||
)
|
)
|
||||||
|
|
@ -57,6 +59,7 @@ from plane.db.models import (
|
||||||
DeployBoard,
|
DeployBoard,
|
||||||
IssueVote,
|
IssueVote,
|
||||||
ProjectPublicMember,
|
ProjectPublicMember,
|
||||||
|
IssueAttachment,
|
||||||
)
|
)
|
||||||
from plane.bgtasks.issue_activites_task import issue_activity
|
from plane.bgtasks.issue_activites_task import issue_activity
|
||||||
from plane.utils.issue_filters import issue_filters
|
from plane.utils.issue_filters import issue_filters
|
||||||
|
|
@ -102,6 +105,28 @@ class ProjectIssuesPublicEndpoint(BaseAPIView):
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
.annotate(cycle_id=F("issue_cycle__cycle_id"))
|
.annotate(cycle_id=F("issue_cycle__cycle_id"))
|
||||||
|
.annotate(
|
||||||
|
link_count=IssueLink.objects.filter(issue=OuterRef("id"))
|
||||||
|
.order_by()
|
||||||
|
.annotate(count=Func(F("id"), function="Count"))
|
||||||
|
.values("count")
|
||||||
|
)
|
||||||
|
.annotate(
|
||||||
|
attachment_count=IssueAttachment.objects.filter(
|
||||||
|
issue=OuterRef("id")
|
||||||
|
)
|
||||||
|
.order_by()
|
||||||
|
.annotate(count=Func(F("id"), function="Count"))
|
||||||
|
.values("count")
|
||||||
|
)
|
||||||
|
.annotate(
|
||||||
|
sub_issues_count=Issue.issue_objects.filter(
|
||||||
|
parent=OuterRef("id")
|
||||||
|
)
|
||||||
|
.order_by()
|
||||||
|
.annotate(count=Func(F("id"), function="Count"))
|
||||||
|
.values("count")
|
||||||
|
)
|
||||||
).distinct()
|
).distinct()
|
||||||
|
|
||||||
issue_queryset = issue_queryset.filter(**filters)
|
issue_queryset = issue_queryset.filter(**filters)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue