Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions apps/api/plane/app/views/cycle/issue.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
# See the LICENSE file for details.

# Python imports
import copy
import json

# Django imports
Expand Down Expand Up @@ -121,8 +120,9 @@ def list(self, request, slug, project_id, cycle_id):
# Apply legacy filters
issue_queryset = issue_queryset.filter(**filters)

# Total count queryset
total_issue_queryset = copy.deepcopy(issue_queryset)
# Total count queryset (alias before annotations; QuerySet chaining
# is immutable so apply_annotations() does not mutate this one).
total_issue_queryset = issue_queryset

# Applying annotations to the issue queryset
issue_queryset = self.apply_annotations(issue_queryset)
Expand Down
6 changes: 3 additions & 3 deletions apps/api/plane/app/views/issue/archive.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
# See the LICENSE file for details.

# Python imports
import copy
import json

# Django imports
Expand Down Expand Up @@ -119,8 +118,9 @@ def list(self, request, slug, project_id):
# Apply legacy filters
issue_queryset = issue_queryset.filter(**filters)

# Total count queryset
total_issue_queryset = copy.deepcopy(issue_queryset)
# Total count queryset (alias before annotations; QuerySet chaining
# is immutable so apply_annotations() does not mutate this one).
total_issue_queryset = issue_queryset

# Applying annotations to the issue queryset
issue_queryset = self.apply_annotations(issue_queryset)
Expand Down
12 changes: 7 additions & 5 deletions apps/api/plane/app/views/issue/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
# See the LICENSE file for details.

# Python imports
import copy
import json

# Django imports
Expand Down Expand Up @@ -269,8 +268,10 @@ def list(self, request, slug, project_id):
# Apply legacy filters
issue_queryset = issue_queryset.filter(**filters, **extra_filters)

# Keeping a copy of the queryset before applying annotations
filtered_issue_queryset = copy.deepcopy(issue_queryset)
# Keeping a reference to the queryset before applying annotations.
# QuerySets are immutable through chaining, so apply_annotations()
# returns a new queryset and leaves this one untouched.
filtered_issue_queryset = issue_queryset

# Applying annotations to the issue queryset
issue_queryset = self.apply_annotations(issue_queryset)
Expand Down Expand Up @@ -1069,8 +1070,9 @@ def get(self, request, slug, project_id):
# Apply legacy filters
issue = issue.filter(**filters)

# Total count queryset
total_issue_queryset = copy.deepcopy(issue)
# Total count queryset (alias before annotations; QuerySet chaining
# is immutable so apply_annotations() does not mutate this one).
total_issue_queryset = issue

# Applying annotations to the issue queryset
issue = self.apply_annotations(issue)
Expand Down
6 changes: 3 additions & 3 deletions apps/api/plane/app/views/module/issue.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
# See the LICENSE file for details.

# Python imports
import copy
import json

from django.db.models import F, Func, OuterRef, Q, Subquery
Expand Down Expand Up @@ -103,8 +102,9 @@ def list(self, request, slug, project_id, module_id):
# Apply legacy filters
issue_queryset = issue_queryset.filter(**filters)

# Total count queryset
total_issue_queryset = copy.deepcopy(issue_queryset)
# Total count queryset (alias before annotations; QuerySet chaining
# is immutable so apply_annotations() does not mutate this one).
total_issue_queryset = issue_queryset

# Apply annotations to the issue queryset
issue_queryset = self.apply_annotations(issue_queryset)
Expand Down
9 changes: 4 additions & 5 deletions apps/api/plane/app/views/view/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
# SPDX-License-Identifier: AGPL-3.0-only
# See the LICENSE file for details.

import copy

# Django imports
from django.db.models import (
Exists,
Expand Down Expand Up @@ -231,9 +229,10 @@ def list(self, request, slug):
# Apply project permission filters to the issue queryset
issue_queryset = issue_queryset.filter(permission_filters)

# Base query for the counts
total_issue_count_queryset = copy.deepcopy(issue_queryset)
total_issue_count_queryset = total_issue_count_queryset.only("id")
# Base query for the counts. QuerySet chaining is immutable, so
# the subsequent apply_annotations() does not mutate this alias;
# .only("id") returns a new queryset.
total_issue_count_queryset = issue_queryset.only("id")

# Apply annotations to the issue queryset
issue_queryset = self.apply_annotations(issue_queryset)
Expand Down
6 changes: 3 additions & 3 deletions apps/api/plane/app/views/workspace/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
# See the LICENSE file for details.

# Python imports
import copy
from datetime import date

from dateutil.relativedelta import relativedelta
Expand Down Expand Up @@ -152,8 +151,9 @@ def get(self, request, slug, user_id):
# Apply legacy filters
issue_queryset = issue_queryset.filter(**filters)

# Total count queryset
total_issue_queryset = copy.deepcopy(issue_queryset)
# Total count queryset (alias before annotations; QuerySet chaining
# is immutable so apply_annotations() does not mutate this one).
total_issue_queryset = issue_queryset

# Apply annotations to the issue queryset
issue_queryset = self.apply_annotations(issue_queryset)
Expand Down