chore: changed the annotate for cycle id (#5892)
This commit is contained in:
parent
d859ab9c39
commit
295f094916
15 changed files with 155 additions and 163 deletions
|
|
@ -16,6 +16,7 @@ from django.db.models import (
|
||||||
Q,
|
Q,
|
||||||
Value,
|
Value,
|
||||||
When,
|
When,
|
||||||
|
Subquery,
|
||||||
)
|
)
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
|
|
||||||
|
|
@ -48,6 +49,7 @@ from plane.db.models import (
|
||||||
Label,
|
Label,
|
||||||
Project,
|
Project,
|
||||||
ProjectMember,
|
ProjectMember,
|
||||||
|
CycleIssue,
|
||||||
)
|
)
|
||||||
|
|
||||||
from .base import BaseAPIView
|
from .base import BaseAPIView
|
||||||
|
|
@ -203,12 +205,10 @@ class IssueAPIEndpoint(BaseAPIView):
|
||||||
issue_queryset = (
|
issue_queryset = (
|
||||||
self.get_queryset()
|
self.get_queryset()
|
||||||
.annotate(
|
.annotate(
|
||||||
cycle_id=Case(
|
cycle_id=Subquery(
|
||||||
When(
|
CycleIssue.objects.filter(
|
||||||
Q(issue_cycle__deleted_at__isnull=True),
|
issue=OuterRef("id"), deleted_at__isnull=True
|
||||||
then=F("issue_cycle__cycle_id"),
|
).values("cycle_id")[:1]
|
||||||
),
|
|
||||||
default=None,
|
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
.annotate(
|
.annotate(
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ import json
|
||||||
|
|
||||||
# Django imports
|
# Django imports
|
||||||
from django.core import serializers
|
from django.core import serializers
|
||||||
from django.db.models import F, Func, OuterRef, Q, Case, When
|
from django.db.models import F, Func, OuterRef, Q, Subquery
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
from django.utils.decorators import method_decorator
|
from django.utils.decorators import method_decorator
|
||||||
from django.views.decorators.gzip import gzip_page
|
from django.views.decorators.gzip import gzip_page
|
||||||
|
|
@ -103,12 +103,10 @@ class CycleIssueViewSet(BaseViewSet):
|
||||||
)
|
)
|
||||||
.filter(**filters)
|
.filter(**filters)
|
||||||
.annotate(
|
.annotate(
|
||||||
cycle_id=Case(
|
cycle_id=Subquery(
|
||||||
When(
|
CycleIssue.objects.filter(
|
||||||
issue_cycle__deleted_at__isnull=True,
|
issue=OuterRef("id"), deleted_at__isnull=True
|
||||||
then=F("issue_cycle__cycle_id"),
|
).values("cycle_id")[:1]
|
||||||
),
|
|
||||||
default=None,
|
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
.annotate(
|
.annotate(
|
||||||
|
|
|
||||||
|
|
@ -42,6 +42,7 @@ from plane.db.models import (
|
||||||
Project,
|
Project,
|
||||||
Widget,
|
Widget,
|
||||||
WorkspaceMember,
|
WorkspaceMember,
|
||||||
|
CycleIssue,
|
||||||
)
|
)
|
||||||
from plane.utils.issue_filters import issue_filters
|
from plane.utils.issue_filters import issue_filters
|
||||||
|
|
||||||
|
|
@ -191,7 +192,13 @@ def dashboard_assigned_issues(self, request, slug):
|
||||||
).select_related("issue"),
|
).select_related("issue"),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
.annotate(cycle_id=F("issue_cycle__cycle_id"))
|
.annotate(
|
||||||
|
cycle_id=Subquery(
|
||||||
|
CycleIssue.objects.filter(
|
||||||
|
issue=OuterRef("id"), deleted_at__isnull=True
|
||||||
|
).values("cycle_id")[:1]
|
||||||
|
)
|
||||||
|
)
|
||||||
.annotate(
|
.annotate(
|
||||||
link_count=IssueLink.objects.filter(issue=OuterRef("id"))
|
link_count=IssueLink.objects.filter(issue=OuterRef("id"))
|
||||||
.order_by()
|
.order_by()
|
||||||
|
|
@ -365,7 +372,13 @@ def dashboard_created_issues(self, request, slug):
|
||||||
.filter(**filters)
|
.filter(**filters)
|
||||||
.select_related("workspace", "project", "state", "parent")
|
.select_related("workspace", "project", "state", "parent")
|
||||||
.prefetch_related("assignees", "labels", "issue_module__module")
|
.prefetch_related("assignees", "labels", "issue_module__module")
|
||||||
.annotate(cycle_id=F("issue_cycle__cycle_id"))
|
.annotate(
|
||||||
|
cycle_id=Subquery(
|
||||||
|
CycleIssue.objects.filter(
|
||||||
|
issue=OuterRef("id"), deleted_at__isnull=True
|
||||||
|
).values("cycle_id")[:1]
|
||||||
|
)
|
||||||
|
)
|
||||||
.annotate(
|
.annotate(
|
||||||
link_count=IssueLink.objects.filter(issue=OuterRef("id"))
|
link_count=IssueLink.objects.filter(issue=OuterRef("id"))
|
||||||
.order_by()
|
.order_by()
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ import json
|
||||||
|
|
||||||
# Django import
|
# Django import
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
from django.db.models import Q, Count, OuterRef, Func, F, Prefetch, Case, When
|
from django.db.models import Q, Count, OuterRef, Func, F, Prefetch, Subquery
|
||||||
from django.core.serializers.json import DjangoJSONEncoder
|
from django.core.serializers.json import DjangoJSONEncoder
|
||||||
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
|
||||||
|
|
@ -26,6 +26,7 @@ from plane.db.models import (
|
||||||
FileAsset,
|
FileAsset,
|
||||||
Project,
|
Project,
|
||||||
ProjectMember,
|
ProjectMember,
|
||||||
|
CycleIssue,
|
||||||
)
|
)
|
||||||
from plane.app.serializers import (
|
from plane.app.serializers import (
|
||||||
IssueCreateSerializer,
|
IssueCreateSerializer,
|
||||||
|
|
@ -113,12 +114,10 @@ class InboxIssueViewSet(BaseViewSet):
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
.annotate(
|
.annotate(
|
||||||
cycle_id=Case(
|
cycle_id=Subquery(
|
||||||
When(
|
CycleIssue.objects.filter(
|
||||||
issue_cycle__deleted_at__isnull=True,
|
issue=OuterRef("id"), deleted_at__isnull=True
|
||||||
then=F("issue_cycle__cycle_id"),
|
).values("cycle_id")[:1]
|
||||||
),
|
|
||||||
default=None,
|
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
.annotate(
|
.annotate(
|
||||||
|
|
@ -203,8 +202,10 @@ class InboxIssueViewSet(BaseViewSet):
|
||||||
ArrayAgg(
|
ArrayAgg(
|
||||||
"issue__labels__id",
|
"issue__labels__id",
|
||||||
distinct=True,
|
distinct=True,
|
||||||
filter=Q(~Q(issue__labels__id__isnull=True)
|
filter=Q(
|
||||||
& Q(issue__label_issue__deleted_at__isnull=True)),
|
~Q(issue__labels__id__isnull=True)
|
||||||
|
& Q(issue__label_issue__deleted_at__isnull=True)
|
||||||
|
),
|
||||||
),
|
),
|
||||||
Value([], output_field=ArrayField(UUIDField())),
|
Value([], output_field=ArrayField(UUIDField())),
|
||||||
)
|
)
|
||||||
|
|
@ -385,8 +386,10 @@ class InboxIssueViewSet(BaseViewSet):
|
||||||
ArrayAgg(
|
ArrayAgg(
|
||||||
"labels__id",
|
"labels__id",
|
||||||
distinct=True,
|
distinct=True,
|
||||||
filter=Q(~Q(labels__id__isnull=True)
|
filter=Q(
|
||||||
& Q(label_issue__deleted_at__isnull=True)),
|
~Q(labels__id__isnull=True)
|
||||||
|
& Q(label_issue__deleted_at__isnull=True)
|
||||||
|
),
|
||||||
),
|
),
|
||||||
Value([], output_field=ArrayField(UUIDField())),
|
Value([], output_field=ArrayField(UUIDField())),
|
||||||
),
|
),
|
||||||
|
|
@ -394,8 +397,10 @@ class InboxIssueViewSet(BaseViewSet):
|
||||||
ArrayAgg(
|
ArrayAgg(
|
||||||
"assignees__id",
|
"assignees__id",
|
||||||
distinct=True,
|
distinct=True,
|
||||||
filter=Q(~Q(assignees__id__isnull=True)
|
filter=Q(
|
||||||
& Q(issue_assignee__deleted_at__isnull=True)),
|
~Q(assignees__id__isnull=True)
|
||||||
|
& Q(issue_assignee__deleted_at__isnull=True)
|
||||||
|
),
|
||||||
),
|
),
|
||||||
Value([], output_field=ArrayField(UUIDField())),
|
Value([], output_field=ArrayField(UUIDField())),
|
||||||
),
|
),
|
||||||
|
|
@ -518,10 +523,12 @@ class InboxIssueViewSet(BaseViewSet):
|
||||||
ArrayAgg(
|
ArrayAgg(
|
||||||
"issue__labels__id",
|
"issue__labels__id",
|
||||||
distinct=True,
|
distinct=True,
|
||||||
filter=Q(~Q(issue__labels__id__isnull=True)
|
filter=Q(
|
||||||
& Q(
|
~Q(issue__labels__id__isnull=True)
|
||||||
issue__label_issue__deleted_at__isnull=True
|
& Q(
|
||||||
)),
|
issue__label_issue__deleted_at__isnull=True
|
||||||
|
)
|
||||||
|
),
|
||||||
),
|
),
|
||||||
Value([], output_field=ArrayField(UUIDField())),
|
Value([], output_field=ArrayField(UUIDField())),
|
||||||
),
|
),
|
||||||
|
|
@ -529,8 +536,12 @@ class InboxIssueViewSet(BaseViewSet):
|
||||||
ArrayAgg(
|
ArrayAgg(
|
||||||
"issue__assignees__id",
|
"issue__assignees__id",
|
||||||
distinct=True,
|
distinct=True,
|
||||||
filter=Q(~Q(issue__assignees__id__isnull=True)
|
filter=Q(
|
||||||
& Q(issue__issue_assignee__deleted_at__isnull=True)),
|
~Q(issue__assignees__id__isnull=True)
|
||||||
|
& Q(
|
||||||
|
issue__issue_assignee__deleted_at__isnull=True
|
||||||
|
)
|
||||||
|
),
|
||||||
),
|
),
|
||||||
Value([], output_field=ArrayField(UUIDField())),
|
Value([], output_field=ArrayField(UUIDField())),
|
||||||
),
|
),
|
||||||
|
|
@ -575,8 +586,10 @@ class InboxIssueViewSet(BaseViewSet):
|
||||||
ArrayAgg(
|
ArrayAgg(
|
||||||
"issue__labels__id",
|
"issue__labels__id",
|
||||||
distinct=True,
|
distinct=True,
|
||||||
filter=Q(~Q(issue__labels__id__isnull=True)
|
filter=Q(
|
||||||
& Q(issue__label_issue__deleted_at__isnull=True)),
|
~Q(issue__labels__id__isnull=True)
|
||||||
|
& Q(issue__label_issue__deleted_at__isnull=True)
|
||||||
|
),
|
||||||
),
|
),
|
||||||
Value([], output_field=ArrayField(UUIDField())),
|
Value([], output_field=ArrayField(UUIDField())),
|
||||||
),
|
),
|
||||||
|
|
@ -584,8 +597,10 @@ class InboxIssueViewSet(BaseViewSet):
|
||||||
ArrayAgg(
|
ArrayAgg(
|
||||||
"issue__assignees__id",
|
"issue__assignees__id",
|
||||||
distinct=True,
|
distinct=True,
|
||||||
filter=Q(~Q(issue__assignees__id__isnull=True)
|
filter=Q(
|
||||||
& Q(issue__issue_assignee__deleted_at__isnull=True)),
|
~Q(issue__assignees__id__isnull=True)
|
||||||
|
& Q(issue__issue_assignee__deleted_at__isnull=True)
|
||||||
|
),
|
||||||
),
|
),
|
||||||
Value([], output_field=ArrayField(UUIDField())),
|
Value([], output_field=ArrayField(UUIDField())),
|
||||||
),
|
),
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ import json
|
||||||
|
|
||||||
# Django imports
|
# Django imports
|
||||||
from django.core.serializers.json import DjangoJSONEncoder
|
from django.core.serializers.json import DjangoJSONEncoder
|
||||||
from django.db.models import F, Func, OuterRef, Q, Prefetch, Exists, Case, When
|
from django.db.models import F, Func, OuterRef, Q, Prefetch, Exists, Subquery
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
from django.utils.decorators import method_decorator
|
from django.utils.decorators import method_decorator
|
||||||
from django.views.decorators.gzip import gzip_page
|
from django.views.decorators.gzip import gzip_page
|
||||||
|
|
@ -27,6 +27,7 @@ from plane.db.models import (
|
||||||
IssueLink,
|
IssueLink,
|
||||||
IssueSubscriber,
|
IssueSubscriber,
|
||||||
IssueReaction,
|
IssueReaction,
|
||||||
|
CycleIssue
|
||||||
)
|
)
|
||||||
from plane.utils.grouper import (
|
from plane.utils.grouper import (
|
||||||
issue_group_values,
|
issue_group_values,
|
||||||
|
|
@ -65,12 +66,10 @@ class IssueArchiveViewSet(BaseViewSet):
|
||||||
.select_related("workspace", "project", "state", "parent")
|
.select_related("workspace", "project", "state", "parent")
|
||||||
.prefetch_related("assignees", "labels", "issue_module__module")
|
.prefetch_related("assignees", "labels", "issue_module__module")
|
||||||
.annotate(
|
.annotate(
|
||||||
cycle_id=Case(
|
cycle_id=Subquery(
|
||||||
When(
|
CycleIssue.objects.filter(
|
||||||
issue_cycle__deleted_at__isnull=True,
|
issue=OuterRef("id"), deleted_at__isnull=True
|
||||||
then=F("issue_cycle__cycle_id"),
|
).values("cycle_id")[:1]
|
||||||
),
|
|
||||||
default=None,
|
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
.annotate(
|
.annotate(
|
||||||
|
|
|
||||||
|
|
@ -14,8 +14,7 @@ from django.db.models import (
|
||||||
Q,
|
Q,
|
||||||
UUIDField,
|
UUIDField,
|
||||||
Value,
|
Value,
|
||||||
When,
|
Subquery,
|
||||||
Case,
|
|
||||||
)
|
)
|
||||||
from django.db.models.functions import Coalesce
|
from django.db.models.functions import Coalesce
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
|
|
@ -44,6 +43,7 @@ from plane.db.models import (
|
||||||
IssueSubscriber,
|
IssueSubscriber,
|
||||||
Project,
|
Project,
|
||||||
ProjectMember,
|
ProjectMember,
|
||||||
|
CycleIssue,
|
||||||
)
|
)
|
||||||
from plane.utils.grouper import (
|
from plane.utils.grouper import (
|
||||||
issue_group_values,
|
issue_group_values,
|
||||||
|
|
@ -86,12 +86,10 @@ class IssueListEndpoint(BaseAPIView):
|
||||||
.select_related("workspace", "project", "state", "parent")
|
.select_related("workspace", "project", "state", "parent")
|
||||||
.prefetch_related("assignees", "labels", "issue_module__module")
|
.prefetch_related("assignees", "labels", "issue_module__module")
|
||||||
.annotate(
|
.annotate(
|
||||||
cycle_id=Case(
|
cycle_id=Subquery(
|
||||||
When(
|
CycleIssue.objects.filter(
|
||||||
issue_cycle__deleted_at__isnull=True,
|
issue=OuterRef("id"), deleted_at__isnull=True
|
||||||
then=F("issue_cycle__cycle_id"),
|
).values("cycle_id")[:1]
|
||||||
),
|
|
||||||
default=None,
|
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
.annotate(
|
.annotate(
|
||||||
|
|
@ -218,12 +216,10 @@ class IssueViewSet(BaseViewSet):
|
||||||
.select_related("workspace", "project", "state", "parent")
|
.select_related("workspace", "project", "state", "parent")
|
||||||
.prefetch_related("assignees", "labels", "issue_module__module")
|
.prefetch_related("assignees", "labels", "issue_module__module")
|
||||||
.annotate(
|
.annotate(
|
||||||
cycle_id=Case(
|
cycle_id=Subquery(
|
||||||
When(
|
CycleIssue.objects.filter(
|
||||||
issue_cycle__deleted_at__isnull=True,
|
issue=OuterRef("id"), deleted_at__isnull=True
|
||||||
then=F("issue_cycle__cycle_id"),
|
).values("cycle_id")[:1]
|
||||||
),
|
|
||||||
default=None,
|
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
.annotate(
|
.annotate(
|
||||||
|
|
@ -786,12 +782,10 @@ class IssuePaginatedViewSet(BaseViewSet):
|
||||||
)
|
)
|
||||||
.prefetch_related("assignees", "labels", "issue_module__module")
|
.prefetch_related("assignees", "labels", "issue_module__module")
|
||||||
.annotate(
|
.annotate(
|
||||||
cycle_id=Case(
|
cycle_id=Subquery(
|
||||||
When(
|
CycleIssue.objects.filter(
|
||||||
issue_cycle__deleted_at__isnull=True,
|
issue=OuterRef("id"), deleted_at__isnull=True
|
||||||
then=F("issue_cycle__cycle_id"),
|
).values("cycle_id")[:1]
|
||||||
),
|
|
||||||
default=None,
|
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
.annotate(
|
.annotate(
|
||||||
|
|
|
||||||
|
|
@ -11,8 +11,7 @@ from django.db.models import (
|
||||||
UUIDField,
|
UUIDField,
|
||||||
Value,
|
Value,
|
||||||
CharField,
|
CharField,
|
||||||
Case,
|
Subquery,
|
||||||
When,
|
|
||||||
)
|
)
|
||||||
from django.core.serializers.json import DjangoJSONEncoder
|
from django.core.serializers.json import DjangoJSONEncoder
|
||||||
from django.db.models.functions import Coalesce
|
from django.db.models.functions import Coalesce
|
||||||
|
|
@ -36,6 +35,7 @@ from plane.db.models import (
|
||||||
Issue,
|
Issue,
|
||||||
FileAsset,
|
FileAsset,
|
||||||
IssueLink,
|
IssueLink,
|
||||||
|
CycleIssue,
|
||||||
)
|
)
|
||||||
from plane.bgtasks.issue_activities_task import issue_activity
|
from plane.bgtasks.issue_activities_task import issue_activity
|
||||||
|
|
||||||
|
|
@ -94,12 +94,10 @@ class IssueRelationViewSet(BaseViewSet):
|
||||||
.select_related("workspace", "project", "state", "parent")
|
.select_related("workspace", "project", "state", "parent")
|
||||||
.prefetch_related("assignees", "labels", "issue_module__module")
|
.prefetch_related("assignees", "labels", "issue_module__module")
|
||||||
.annotate(
|
.annotate(
|
||||||
cycle_id=Case(
|
cycle_id=Subquery(
|
||||||
When(
|
CycleIssue.objects.filter(
|
||||||
issue_cycle__deleted_at__isnull=True,
|
issue=OuterRef("id"), deleted_at__isnull=True
|
||||||
then=F("issue_cycle__cycle_id"),
|
).values("cycle_id")[:1]
|
||||||
),
|
|
||||||
default=None,
|
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
.annotate(
|
.annotate(
|
||||||
|
|
@ -141,9 +139,11 @@ class IssueRelationViewSet(BaseViewSet):
|
||||||
ArrayAgg(
|
ArrayAgg(
|
||||||
"assignees__id",
|
"assignees__id",
|
||||||
distinct=True,
|
distinct=True,
|
||||||
filter=Q(~Q(assignees__id__isnull=True)
|
filter=Q(
|
||||||
& Q(assignees__member_project__is_active=True)
|
~Q(assignees__id__isnull=True)
|
||||||
& Q(issue_assignee__deleted_at__isnull=True)),
|
& Q(assignees__member_project__is_active=True)
|
||||||
|
& Q(issue_assignee__deleted_at__isnull=True)
|
||||||
|
),
|
||||||
),
|
),
|
||||||
Value([], output_field=ArrayField(UUIDField())),
|
Value([], output_field=ArrayField(UUIDField())),
|
||||||
),
|
),
|
||||||
|
|
|
||||||
|
|
@ -3,16 +3,7 @@ import json
|
||||||
|
|
||||||
# Django imports
|
# Django imports
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
from django.db.models import (
|
from django.db.models import OuterRef, Func, F, Q, Value, UUIDField, Subquery
|
||||||
OuterRef,
|
|
||||||
Func,
|
|
||||||
F,
|
|
||||||
Q,
|
|
||||||
Value,
|
|
||||||
UUIDField,
|
|
||||||
Case,
|
|
||||||
When,
|
|
||||||
)
|
|
||||||
from django.utils.decorators import method_decorator
|
from django.utils.decorators import method_decorator
|
||||||
from django.views.decorators.gzip import gzip_page
|
from django.views.decorators.gzip import gzip_page
|
||||||
from django.contrib.postgres.aggregates import ArrayAgg
|
from django.contrib.postgres.aggregates import ArrayAgg
|
||||||
|
|
@ -31,6 +22,7 @@ from plane.db.models import (
|
||||||
Issue,
|
Issue,
|
||||||
IssueLink,
|
IssueLink,
|
||||||
FileAsset,
|
FileAsset,
|
||||||
|
CycleIssue,
|
||||||
)
|
)
|
||||||
from plane.bgtasks.issue_activities_task import issue_activity
|
from plane.bgtasks.issue_activities_task import issue_activity
|
||||||
from plane.utils.user_timezone_converter import user_timezone_converter
|
from plane.utils.user_timezone_converter import user_timezone_converter
|
||||||
|
|
@ -51,12 +43,10 @@ class SubIssuesEndpoint(BaseAPIView):
|
||||||
.select_related("workspace", "project", "state", "parent")
|
.select_related("workspace", "project", "state", "parent")
|
||||||
.prefetch_related("assignees", "labels", "issue_module__module")
|
.prefetch_related("assignees", "labels", "issue_module__module")
|
||||||
.annotate(
|
.annotate(
|
||||||
cycle_id=Case(
|
cycle_id=Subquery(
|
||||||
When(
|
CycleIssue.objects.filter(
|
||||||
issue_cycle__deleted_at__isnull=True,
|
issue=OuterRef("id"), deleted_at__isnull=True
|
||||||
then=F("issue_cycle__cycle_id"),
|
).values("cycle_id")[:1]
|
||||||
),
|
|
||||||
default=None,
|
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
.annotate(
|
.annotate(
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,7 @@
|
||||||
# Python imports
|
# Python imports
|
||||||
import json
|
import json
|
||||||
|
|
||||||
from django.db.models import (
|
from django.db.models import F, Func, OuterRef, Q, Subquery
|
||||||
F,
|
|
||||||
Func,
|
|
||||||
OuterRef,
|
|
||||||
Q,
|
|
||||||
Case,
|
|
||||||
When,
|
|
||||||
)
|
|
||||||
|
|
||||||
# Django Imports
|
# Django Imports
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
|
|
@ -30,6 +23,7 @@ from plane.db.models import (
|
||||||
IssueLink,
|
IssueLink,
|
||||||
ModuleIssue,
|
ModuleIssue,
|
||||||
Project,
|
Project,
|
||||||
|
CycleIssue,
|
||||||
)
|
)
|
||||||
from plane.utils.grouper import (
|
from plane.utils.grouper import (
|
||||||
issue_group_values,
|
issue_group_values,
|
||||||
|
|
@ -68,12 +62,10 @@ class ModuleIssueViewSet(BaseViewSet):
|
||||||
.select_related("workspace", "project", "state", "parent")
|
.select_related("workspace", "project", "state", "parent")
|
||||||
.prefetch_related("assignees", "labels", "issue_module__module")
|
.prefetch_related("assignees", "labels", "issue_module__module")
|
||||||
.annotate(
|
.annotate(
|
||||||
cycle_id=Case(
|
cycle_id=Subquery(
|
||||||
When(
|
CycleIssue.objects.filter(
|
||||||
issue_cycle__deleted_at__isnull=True,
|
issue=OuterRef("id"), deleted_at__isnull=True
|
||||||
then=F("issue_cycle__cycle_id"),
|
).values("cycle_id")[:1]
|
||||||
),
|
|
||||||
default=None,
|
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
.annotate(
|
.annotate(
|
||||||
|
|
|
||||||
|
|
@ -9,8 +9,7 @@ from django.db.models import (
|
||||||
Q,
|
Q,
|
||||||
UUIDField,
|
UUIDField,
|
||||||
Value,
|
Value,
|
||||||
Case,
|
Subquery,
|
||||||
When,
|
|
||||||
)
|
)
|
||||||
from django.db.models.functions import Coalesce
|
from django.db.models.functions import Coalesce
|
||||||
from django.utils.decorators import method_decorator
|
from django.utils.decorators import method_decorator
|
||||||
|
|
@ -38,6 +37,7 @@ from plane.db.models import (
|
||||||
WorkspaceMember,
|
WorkspaceMember,
|
||||||
ProjectMember,
|
ProjectMember,
|
||||||
Project,
|
Project,
|
||||||
|
CycleIssue,
|
||||||
)
|
)
|
||||||
from plane.utils.grouper import (
|
from plane.utils.grouper import (
|
||||||
issue_group_values,
|
issue_group_values,
|
||||||
|
|
@ -208,12 +208,10 @@ class WorkspaceViewIssuesViewSet(BaseViewSet):
|
||||||
.select_related("workspace", "project", "state", "parent")
|
.select_related("workspace", "project", "state", "parent")
|
||||||
.prefetch_related("assignees", "labels", "issue_module__module")
|
.prefetch_related("assignees", "labels", "issue_module__module")
|
||||||
.annotate(
|
.annotate(
|
||||||
cycle_id=Case(
|
cycle_id=Subquery(
|
||||||
When(
|
CycleIssue.objects.filter(
|
||||||
issue_cycle__deleted_at__isnull=True,
|
issue=OuterRef("id"), deleted_at__isnull=True
|
||||||
then=F("issue_cycle__cycle_id"),
|
).values("cycle_id")[:1]
|
||||||
),
|
|
||||||
default=None,
|
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
.annotate(
|
.annotate(
|
||||||
|
|
@ -291,12 +289,10 @@ class WorkspaceViewIssuesViewSet(BaseViewSet):
|
||||||
self.get_queryset()
|
self.get_queryset()
|
||||||
.filter(**filters)
|
.filter(**filters)
|
||||||
.annotate(
|
.annotate(
|
||||||
cycle_id=Case(
|
cycle_id=Subquery(
|
||||||
When(
|
CycleIssue.objects.filter(
|
||||||
issue_cycle__deleted_at__isnull=True,
|
issue=OuterRef("id"), deleted_at__isnull=True
|
||||||
then=F("issue_cycle__cycle_id"),
|
).values("cycle_id")[:1]
|
||||||
),
|
|
||||||
default=None,
|
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -8,12 +8,11 @@ from django.core.serializers.json import DjangoJSONEncoder
|
||||||
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 import (
|
from django.db.models import (
|
||||||
F,
|
|
||||||
Q,
|
Q,
|
||||||
UUIDField,
|
UUIDField,
|
||||||
Value,
|
Value,
|
||||||
Case,
|
Subquery,
|
||||||
When,
|
OuterRef,
|
||||||
)
|
)
|
||||||
from django.db.models.functions import Coalesce
|
from django.db.models.functions import Coalesce
|
||||||
from django.utils.decorators import method_decorator
|
from django.utils.decorators import method_decorator
|
||||||
|
|
@ -36,7 +35,6 @@ from plane.db.models import (
|
||||||
DraftIssue,
|
DraftIssue,
|
||||||
CycleIssue,
|
CycleIssue,
|
||||||
ModuleIssue,
|
ModuleIssue,
|
||||||
DraftIssueModule,
|
|
||||||
DraftIssueCycle,
|
DraftIssueCycle,
|
||||||
Workspace,
|
Workspace,
|
||||||
FileAsset,
|
FileAsset,
|
||||||
|
|
@ -56,14 +54,11 @@ class WorkspaceDraftIssueViewSet(BaseViewSet):
|
||||||
.prefetch_related(
|
.prefetch_related(
|
||||||
"assignees", "labels", "draft_issue_module__module"
|
"assignees", "labels", "draft_issue_module__module"
|
||||||
)
|
)
|
||||||
.annotate(cycle_id=F("draft_issue_cycle__cycle_id"))
|
|
||||||
.annotate(
|
.annotate(
|
||||||
cycle_id=Case(
|
cycle_id=Subquery(
|
||||||
When(
|
DraftIssueCycle.objects.filter(
|
||||||
draft_issue_cycle__deleted_at__isnull=True,
|
draft_issue=OuterRef("id"), deleted_at__isnull=True
|
||||||
then=F("draft_issue_cycle__cycle_id"),
|
).values("cycle_id")[:1]
|
||||||
),
|
|
||||||
default=None,
|
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
.annotate(
|
.annotate(
|
||||||
|
|
@ -82,9 +77,11 @@ class WorkspaceDraftIssueViewSet(BaseViewSet):
|
||||||
ArrayAgg(
|
ArrayAgg(
|
||||||
"assignees__id",
|
"assignees__id",
|
||||||
distinct=True,
|
distinct=True,
|
||||||
filter=Q(~Q(assignees__id__isnull=True)
|
filter=Q(
|
||||||
& Q(assignees__member_project__is_active=True)
|
~Q(assignees__id__isnull=True)
|
||||||
& Q(draft_issue_assignee__deleted_at__isnull=True)),
|
& Q(assignees__member_project__is_active=True)
|
||||||
|
& Q(draft_issue_assignee__deleted_at__isnull=True)
|
||||||
|
),
|
||||||
),
|
),
|
||||||
Value([], output_field=ArrayField(UUIDField())),
|
Value([], output_field=ArrayField(UUIDField())),
|
||||||
),
|
),
|
||||||
|
|
@ -92,11 +89,13 @@ class WorkspaceDraftIssueViewSet(BaseViewSet):
|
||||||
ArrayAgg(
|
ArrayAgg(
|
||||||
"draft_issue_module__module_id",
|
"draft_issue_module__module_id",
|
||||||
distinct=True,
|
distinct=True,
|
||||||
filter=Q(~Q(draft_issue_module__module_id__isnull=True)
|
filter=Q(
|
||||||
& Q(
|
~Q(draft_issue_module__module_id__isnull=True)
|
||||||
draft_issue_module__module__archived_at__isnull=True
|
& Q(
|
||||||
)
|
draft_issue_module__module__archived_at__isnull=True
|
||||||
& Q(draft_issue_module__deleted_at__isnull=True)),
|
)
|
||||||
|
& Q(draft_issue_module__deleted_at__isnull=True)
|
||||||
|
),
|
||||||
),
|
),
|
||||||
Value([], output_field=ArrayField(UUIDField())),
|
Value([], output_field=ArrayField(UUIDField())),
|
||||||
),
|
),
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,7 @@ from django.db.models import (
|
||||||
Q,
|
Q,
|
||||||
Value,
|
Value,
|
||||||
When,
|
When,
|
||||||
|
Subquery,
|
||||||
)
|
)
|
||||||
from django.db.models.fields import DateField
|
from django.db.models.fields import DateField
|
||||||
from django.db.models.functions import Cast, ExtractWeek
|
from django.db.models.functions import Cast, ExtractWeek
|
||||||
|
|
@ -121,12 +122,10 @@ class WorkspaceUserProfileIssuesEndpoint(BaseAPIView):
|
||||||
.select_related("workspace", "project", "state", "parent")
|
.select_related("workspace", "project", "state", "parent")
|
||||||
.prefetch_related("assignees", "labels", "issue_module__module")
|
.prefetch_related("assignees", "labels", "issue_module__module")
|
||||||
.annotate(
|
.annotate(
|
||||||
cycle_id=Case(
|
cycle_id=Subquery(
|
||||||
When(
|
CycleIssue.objects.filter(
|
||||||
issue_cycle__deleted_at__isnull=True,
|
issue=OuterRef("id"), deleted_at__isnull=True
|
||||||
then=F("issue_cycle__cycle_id"),
|
).values("cycle_id")[:1]
|
||||||
),
|
|
||||||
default=None,
|
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
.annotate(
|
.annotate(
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,6 @@ from django.db import models
|
||||||
# Module imports
|
# Module imports
|
||||||
from plane.utils.html_processor import strip_tags
|
from plane.utils.html_processor import strip_tags
|
||||||
|
|
||||||
from .project import ProjectBaseModel
|
|
||||||
from .base import BaseModel
|
from .base import BaseModel
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,6 @@ from django.conf import settings
|
||||||
from django.db import models
|
from django.db import models
|
||||||
|
|
||||||
# Module import
|
# Module import
|
||||||
from .base import BaseModel
|
|
||||||
from .project import ProjectBaseModel
|
|
||||||
from .workspace import WorkspaceBaseModel
|
from .workspace import WorkspaceBaseModel
|
||||||
from plane.utils.issue_filters import issue_filters
|
from plane.utils.issue_filters import issue_filters
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,7 @@ from django.db.models import (
|
||||||
OuterRef,
|
OuterRef,
|
||||||
Func,
|
Func,
|
||||||
CharField,
|
CharField,
|
||||||
|
Subquery,
|
||||||
)
|
)
|
||||||
from django.db.models.functions import Concat
|
from django.db.models.functions import Concat
|
||||||
|
|
||||||
|
|
@ -62,6 +63,7 @@ from plane.db.models import (
|
||||||
IssueVote,
|
IssueVote,
|
||||||
ProjectPublicMember,
|
ProjectPublicMember,
|
||||||
FileAsset,
|
FileAsset,
|
||||||
|
CycleIssue,
|
||||||
)
|
)
|
||||||
from plane.bgtasks.issue_activities_task import issue_activity
|
from plane.bgtasks.issue_activities_task import issue_activity
|
||||||
from plane.utils.issue_filters import issue_filters
|
from plane.utils.issue_filters import issue_filters
|
||||||
|
|
@ -107,12 +109,10 @@ class ProjectIssuesPublicEndpoint(BaseAPIView):
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
.annotate(
|
.annotate(
|
||||||
cycle_id=Case(
|
cycle_id=Subquery(
|
||||||
When(
|
CycleIssue.objects.filter(
|
||||||
issue_cycle__deleted_at__isnull=True,
|
issue=OuterRef("id"), deleted_at__isnull=True
|
||||||
then=F("issue_cycle__cycle_id"),
|
).values("cycle_id")[:1]
|
||||||
),
|
|
||||||
default=None,
|
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
.annotate(
|
.annotate(
|
||||||
|
|
@ -704,12 +704,10 @@ class IssueRetrievePublicEndpoint(BaseAPIView):
|
||||||
.select_related("workspace", "project", "state", "parent")
|
.select_related("workspace", "project", "state", "parent")
|
||||||
.prefetch_related("assignees", "labels", "issue_module__module")
|
.prefetch_related("assignees", "labels", "issue_module__module")
|
||||||
.annotate(
|
.annotate(
|
||||||
cycle_id=Case(
|
cycle_id=Subquery(
|
||||||
When(
|
CycleIssue.objects.filter(
|
||||||
issue_cycle__deleted_at__isnull=True,
|
issue=OuterRef("id"), deleted_at__isnull=True
|
||||||
then=F("issue_cycle__cycle_id"),
|
).values("cycle_id")[:1]
|
||||||
),
|
|
||||||
default=None,
|
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
.annotate(
|
.annotate(
|
||||||
|
|
@ -728,9 +726,11 @@ class IssueRetrievePublicEndpoint(BaseAPIView):
|
||||||
ArrayAgg(
|
ArrayAgg(
|
||||||
"assignees__id",
|
"assignees__id",
|
||||||
distinct=True,
|
distinct=True,
|
||||||
filter=Q(~Q(assignees__id__isnull=True)
|
filter=Q(
|
||||||
& Q(assignees__member_project__is_active=True)
|
~Q(assignees__id__isnull=True)
|
||||||
& Q(issue_assignee__deleted_at__isnull=True)),
|
& Q(assignees__member_project__is_active=True)
|
||||||
|
& Q(issue_assignee__deleted_at__isnull=True)
|
||||||
|
),
|
||||||
),
|
),
|
||||||
Value([], output_field=ArrayField(UUIDField())),
|
Value([], output_field=ArrayField(UUIDField())),
|
||||||
),
|
),
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue