Skip to content

Commit

Permalink
fix: issues n plus 1 (#1785)
Browse files Browse the repository at this point in the history
  • Loading branch information
pablohashescobar committed Aug 11, 2023
1 parent f562fcd commit 8373f20
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
12 changes: 12 additions & 0 deletions apiserver/plane/api/views/issue.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,12 @@ def get(self, request, slug):
.annotate(count=Func(F("id"), function="Count"))
.values("count")
)
.prefetch_related(
Prefetch(
"issue_reactions",
queryset=IssueReaction.objects.select_related("actor"),
)
)
.filter(**filters)
)

Expand Down Expand Up @@ -744,6 +750,12 @@ def get(self, request, slug, project_id, issue_id):
.annotate(count=Func(F("id"), function="Count"))
.values("count")
)
.prefetch_related(
Prefetch(
"issue_reactions",
queryset=IssueReaction.objects.select_related("actor"),
)
)
)

state_distribution = (
Expand Down
7 changes: 7 additions & 0 deletions apiserver/plane/api/views/view.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
IssueView,
Issue,
IssueViewFavorite,
IssueReaction,
)
from plane.utils.issue_filters import issue_filters

Expand Down Expand Up @@ -77,6 +78,12 @@ def get(self, request, slug, project_id, view_id):
.select_related("parent")
.prefetch_related("assignees")
.prefetch_related("labels")
.prefetch_related(
Prefetch(
"issue_reactions",
queryset=IssueReaction.objects.select_related("actor"),
)
)
)

serializer = IssueLiteSerializer(issues, many=True)
Expand Down

0 comments on commit 8373f20

Please sign in to comment.