dev: optimize public issues list endpoint

This commit is contained in:
pablohashescobar 2023-08-30 19:01:09 +05:30
parent a50cf266bd
commit cf706b7977
2 changed files with 7 additions and 1 deletions

View File

@ -561,7 +561,7 @@ class CommentReactionSerializer(BaseSerializer):
class IssueVoteSerializer(BaseSerializer):
class Meta:
model = IssueVote
fields = ["issue", "vote", "workspace_id", "project_id", "actor"]
fields = ["issue", "vote", "workspace", "project", "actor",]
read_only_fields = fields

View File

@ -2060,6 +2060,12 @@ class ProjectIssuesPublicEndpoint(BaseAPIView):
queryset=IssueReaction.objects.select_related("actor"),
)
)
.prefetch_related(
Prefetch(
"votes",
queryset=IssueVote.objects.select_related("actor"),
)
)
.filter(**filters)
.annotate(cycle_id=F("issue_cycle__cycle_id"))
.annotate(module_id=F("issue_module__module_id"))