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
|
|
@ -14,6 +14,7 @@ from django.db.models import (
|
|||
Q,
|
||||
Value,
|
||||
When,
|
||||
Subquery,
|
||||
)
|
||||
from django.db.models.fields import DateField
|
||||
from django.db.models.functions import Cast, ExtractWeek
|
||||
|
|
@ -121,12 +122,10 @@ class WorkspaceUserProfileIssuesEndpoint(BaseAPIView):
|
|||
.select_related("workspace", "project", "state", "parent")
|
||||
.prefetch_related("assignees", "labels", "issue_module__module")
|
||||
.annotate(
|
||||
cycle_id=Case(
|
||||
When(
|
||||
issue_cycle__deleted_at__isnull=True,
|
||||
then=F("issue_cycle__cycle_id"),
|
||||
),
|
||||
default=None,
|
||||
cycle_id=Subquery(
|
||||
CycleIssue.objects.filter(
|
||||
issue=OuterRef("id"), deleted_at__isnull=True
|
||||
).values("cycle_id")[:1]
|
||||
)
|
||||
)
|
||||
.annotate(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue