Skip to content

Commit

Permalink
[WEB-2693] chore: removed the deleted cycles from the issue list (#5868)
Browse files Browse the repository at this point in the history
* chore: added the deleted cycles from list

* chore: removed the extra annotation

* chore: removed the frontend comment
  • Loading branch information
NarayanBavisetti authored Oct 18, 2024
1 parent 2982cd4 commit db91942
Show file tree
Hide file tree
Showing 12 changed files with 174 additions and 28 deletions.
10 changes: 9 additions & 1 deletion apiserver/plane/api/views/issue.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,15 @@ def get(self, request, slug, project_id, pk=None):

issue_queryset = (
self.get_queryset()
.annotate(cycle_id=F("issue_cycle__cycle_id"))
.annotate(
cycle_id=Case(
When(
Q(issue_cycle__cycle__deleted_at__isnull=True),
then=F("issue_cycle__cycle_id"),
),
default=None,
)
)
.annotate(
link_count=IssueLink.objects.filter(issue=OuterRef("id"))
.order_by()
Expand Down
12 changes: 10 additions & 2 deletions apiserver/plane/app/views/cycle/issue.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

# Django imports
from django.core import serializers
from django.db.models import F, Func, OuterRef, Q
from django.db.models import F, Func, OuterRef, Q, Case, When
from django.utils import timezone
from django.utils.decorators import method_decorator
from django.views.decorators.gzip import gzip_page
Expand Down Expand Up @@ -102,7 +102,15 @@ def list(self, request, slug, project_id, cycle_id):
"issue_cycle__cycle",
)
.filter(**filters)
.annotate(cycle_id=F("issue_cycle__cycle_id"))
.annotate(
cycle_id=Case(
When(
issue_cycle__cycle__deleted_at__isnull=True,
then=F("issue_cycle__cycle_id"),
),
default=None,
)
)
.annotate(
link_count=IssueLink.objects.filter(issue=OuterRef("id"))
.order_by()
Expand Down
12 changes: 10 additions & 2 deletions apiserver/plane/app/views/inbox/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

# Django import
from django.utils import timezone
from django.db.models import Q, Count, OuterRef, Func, F, Prefetch
from django.db.models import Q, Count, OuterRef, Func, F, Prefetch, Case, When
from django.core.serializers.json import DjangoJSONEncoder
from django.contrib.postgres.aggregates import ArrayAgg
from django.contrib.postgres.fields import ArrayField
Expand Down Expand Up @@ -112,7 +112,15 @@ def get_queryset(self):
),
)
)
.annotate(cycle_id=F("issue_cycle__cycle_id"))
.annotate(
cycle_id=Case(
When(
issue_cycle__cycle__deleted_at__isnull=True,
then=F("issue_cycle__cycle_id"),
),
default=None,
)
)
.annotate(
link_count=IssueLink.objects.filter(issue=OuterRef("id"))
.order_by()
Expand Down
19 changes: 10 additions & 9 deletions apiserver/plane/app/views/issue/archive.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,7 @@

# Django imports
from django.core.serializers.json import DjangoJSONEncoder
from django.db.models import (
F,
Func,
OuterRef,
Q,
Prefetch,
Exists,
)
from django.db.models import F, Func, OuterRef, Q, Prefetch, Exists, Case, When
from django.utils import timezone
from django.utils.decorators import method_decorator
from django.views.decorators.gzip import gzip_page
Expand Down Expand Up @@ -71,7 +64,15 @@ def get_queryset(self):
.filter(workspace__slug=self.kwargs.get("slug"))
.select_related("workspace", "project", "state", "parent")
.prefetch_related("assignees", "labels", "issue_module__module")
.annotate(cycle_id=F("issue_cycle__cycle_id"))
.annotate(
cycle_id=Case(
When(
issue_cycle__cycle__deleted_at__isnull=True,
then=F("issue_cycle__cycle_id"),
),
default=None,
)
)
.annotate(
link_count=IssueLink.objects.filter(issue=OuterRef("id"))
.order_by()
Expand Down
32 changes: 29 additions & 3 deletions apiserver/plane/app/views/issue/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
Q,
UUIDField,
Value,
When,
Case,
)
from django.db.models.functions import Coalesce
from django.utils import timezone
Expand Down Expand Up @@ -83,7 +85,15 @@ def get(self, request, slug, project_id):
.filter(workspace__slug=self.kwargs.get("slug"))
.select_related("workspace", "project", "state", "parent")
.prefetch_related("assignees", "labels", "issue_module__module")
.annotate(cycle_id=F("issue_cycle__cycle_id"))
.annotate(
cycle_id=Case(
When(
issue_cycle__cycle__deleted_at__isnull=True,
then=F("issue_cycle__cycle_id"),
),
default=None,
)
)
.annotate(
link_count=IssueLink.objects.filter(issue=OuterRef("id"))
.order_by()
Expand Down Expand Up @@ -207,7 +217,15 @@ def get_queryset(self):
.filter(workspace__slug=self.kwargs.get("slug"))
.select_related("workspace", "project", "state", "parent")
.prefetch_related("assignees", "labels", "issue_module__module")
.annotate(cycle_id=F("issue_cycle__cycle_id"))
.annotate(
cycle_id=Case(
When(
issue_cycle__cycle__deleted_at__isnull=True,
then=F("issue_cycle__cycle_id"),
),
default=None,
)
)
.annotate(
link_count=IssueLink.objects.filter(issue=OuterRef("id"))
.order_by()
Expand Down Expand Up @@ -757,7 +775,15 @@ def get_queryset(self):
"workspace", "project", "state", "parent"
)
.prefetch_related("assignees", "labels", "issue_module__module")
.annotate(cycle_id=F("issue_cycle__cycle_id"))
.annotate(
cycle_id=Case(
When(
issue_cycle__cycle__deleted_at__isnull=True,
then=F("issue_cycle__cycle_id"),
),
default=None,
)
)
.annotate(
link_count=IssueLink.objects.filter(issue=OuterRef("id"))
.order_by()
Expand Down
22 changes: 20 additions & 2 deletions apiserver/plane/app/views/issue/relation.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,17 @@

# Django imports
from django.utils import timezone
from django.db.models import Q, OuterRef, F, Func, UUIDField, Value, CharField
from django.db.models import (
Q,
OuterRef,
F,
Func,
UUIDField,
Value,
CharField,
Case,
When,
)
from django.core.serializers.json import DjangoJSONEncoder
from django.db.models.functions import Coalesce
from django.contrib.postgres.aggregates import ArrayAgg
Expand Down Expand Up @@ -83,7 +93,15 @@ def list(self, request, slug, project_id, issue_id):
Issue.issue_objects.filter(workspace__slug=slug)
.select_related("workspace", "project", "state", "parent")
.prefetch_related("assignees", "labels", "issue_module__module")
.annotate(cycle_id=F("issue_cycle__cycle_id"))
.annotate(
cycle_id=Case(
When(
issue_cycle__cycle__deleted_at__isnull=True,
then=F("issue_cycle__cycle_id"),
),
default=None,
)
)
.annotate(
link_count=IssueLink.objects.filter(issue=OuterRef("id"))
.order_by()
Expand Down
12 changes: 11 additions & 1 deletion apiserver/plane/app/views/issue/sub_issue.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
Q,
Value,
UUIDField,
Case,
When,
)
from django.utils.decorators import method_decorator
from django.views.decorators.gzip import gzip_page
Expand Down Expand Up @@ -48,7 +50,15 @@ def get(self, request, slug, project_id, issue_id):
)
.select_related("workspace", "project", "state", "parent")
.prefetch_related("assignees", "labels", "issue_module__module")
.annotate(cycle_id=F("issue_cycle__cycle_id"))
.annotate(
cycle_id=Case(
When(
issue_cycle__cycle__deleted_at__isnull=True,
then=F("issue_cycle__cycle_id"),
),
default=None,
)
)
.annotate(
link_count=IssueLink.objects.filter(issue=OuterRef("id"))
.order_by()
Expand Down
12 changes: 11 additions & 1 deletion apiserver/plane/app/views/module/issue.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
Func,
OuterRef,
Q,
Case,
When,
)

# Django Imports
Expand Down Expand Up @@ -65,7 +67,15 @@ def get_queryset(self):
)
.select_related("workspace", "project", "state", "parent")
.prefetch_related("assignees", "labels", "issue_module__module")
.annotate(cycle_id=F("issue_cycle__cycle_id"))
.annotate(
cycle_id=Case(
When(
issue_cycle__cycle__deleted_at__isnull=True,
then=F("issue_cycle__cycle_id"),
),
default=None,
)
)
.annotate(
link_count=IssueLink.objects.filter(issue=OuterRef("id"))
.order_by()
Expand Down
22 changes: 20 additions & 2 deletions apiserver/plane/app/views/view/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
Q,
UUIDField,
Value,
Case,
When,
)
from django.db.models.functions import Coalesce
from django.utils.decorators import method_decorator
Expand Down Expand Up @@ -205,7 +207,15 @@ def get_queryset(self):
)
.select_related("workspace", "project", "state", "parent")
.prefetch_related("assignees", "labels", "issue_module__module")
.annotate(cycle_id=F("issue_cycle__cycle_id"))
.annotate(
cycle_id=Case(
When(
issue_cycle__cycle__deleted_at__isnull=True,
then=F("issue_cycle__cycle_id"),
),
default=None,
)
)
.annotate(
link_count=IssueLink.objects.filter(issue=OuterRef("id"))
.order_by()
Expand Down Expand Up @@ -275,7 +285,15 @@ def list(self, request, slug):
issue_queryset = (
self.get_queryset()
.filter(**filters)
.annotate(cycle_id=F("issue_cycle__cycle_id"))
.annotate(
cycle_id=Case(
When(
issue_cycle__cycle__deleted_at__isnull=True,
then=F("issue_cycle__cycle_id"),
),
default=None,
)
)
)

# check for the project member role, if the role is 5 then check for the guest_view_all_features if it is true then show all the issues else show only the issues created by the user
Expand Down
19 changes: 17 additions & 2 deletions apiserver/plane/app/views/workspace/draft.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
Q,
UUIDField,
Value,
Case,
When,
)
from django.db.models.functions import Coalesce
from django.utils.decorators import method_decorator
Expand Down Expand Up @@ -55,6 +57,15 @@ def get_queryset(self):
"assignees", "labels", "draft_issue_module__module"
)
.annotate(cycle_id=F("draft_issue_cycle__cycle_id"))
.annotate(
cycle_id=Case(
When(
issue_cycle__cycle__deleted_at__isnull=True,
then=F("issue_cycle__cycle_id"),
),
default=None,
)
)
.annotate(
label_ids=Coalesce(
ArrayAgg(
Expand All @@ -81,8 +92,12 @@ def get_queryset(self):
"draft_issue_module__module_id",
distinct=True,
filter=~Q(draft_issue_module__module_id__isnull=True)
& Q(draft_issue_module__module__archived_at__isnull=True)
& Q(draft_issue_module__module__deleted_at__isnull=True),
& Q(
draft_issue_module__module__archived_at__isnull=True
)
& Q(
draft_issue_module__module__deleted_at__isnull=True
),
),
Value([], output_field=ArrayField(UUIDField())),
),
Expand Down
10 changes: 9 additions & 1 deletion apiserver/plane/app/views/workspace/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,15 @@ def get(self, request, slug, user_id):
.filter(**filters)
.select_related("workspace", "project", "state", "parent")
.prefetch_related("assignees", "labels", "issue_module__module")
.annotate(cycle_id=F("issue_cycle__cycle_id"))
.annotate(
cycle_id=Case(
When(
issue_cycle__cycle__deleted_at__isnull=True,
then=F("issue_cycle__cycle_id"),
),
default=None,
)
)
.annotate(
link_count=IssueLink.objects.filter(issue=OuterRef("id"))
.order_by()
Expand Down
20 changes: 18 additions & 2 deletions apiserver/plane/space/views/issue.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,15 @@ def get(self, request, anchor):
queryset=IssueVote.objects.select_related("actor"),
)
)
.annotate(cycle_id=F("issue_cycle__cycle_id"))
.annotate(
cycle_id=Case(
When(
issue_cycle__cycle__deleted_at__isnull=True,
then=F("issue_cycle__cycle_id"),
),
default=None,
)
)
.annotate(
link_count=IssueLink.objects.filter(issue=OuterRef("id"))
.order_by()
Expand Down Expand Up @@ -695,7 +703,15 @@ def get(self, request, anchor, issue_id):
)
.select_related("workspace", "project", "state", "parent")
.prefetch_related("assignees", "labels", "issue_module__module")
.annotate(cycle_id=F("issue_cycle__cycle_id"))
.annotate(
cycle_id=Case(
When(
issue_cycle__cycle__deleted_at__isnull=True,
then=F("issue_cycle__cycle_id"),
),
default=None,
)
)
.annotate(
label_ids=Coalesce(
ArrayAgg(
Expand Down

0 comments on commit db91942

Please sign in to comment.