chore: changed the annotate for cycle id (#5892)

This commit is contained in:
Bavisetti Narayan 2024-10-22 19:02:05 +05:30 committed by GitHub
parent d859ab9c39
commit 295f094916
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
15 changed files with 155 additions and 163 deletions

View file

@ -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(