forked from github/plane
fix: n+1 in issue history and issue automation tasks (#1994)
This commit is contained in:
parent
3a41ec7442
commit
abcdebef85
@ -493,6 +493,12 @@ class IssueActivityEndpoint(BaseAPIView):
|
||||
.filter(project__project_projectmember__member=self.request.user)
|
||||
.order_by("created_at")
|
||||
.select_related("actor", "issue", "project", "workspace")
|
||||
.prefetch_related(
|
||||
Prefetch(
|
||||
"comment_reactions",
|
||||
queryset=CommentReaction.objects.select_related("actor"),
|
||||
)
|
||||
)
|
||||
)
|
||||
issue_activities = IssueActivitySerializer(issue_activities, many=True).data
|
||||
issue_comments = IssueCommentSerializer(issue_comments, many=True).data
|
||||
|
@ -64,7 +64,7 @@ def archive_old_issues():
|
||||
issues_to_update.append(issue)
|
||||
|
||||
# Bulk Update the issues and log the activity
|
||||
Issue.objects.bulk_update(
|
||||
updated_issues = Issue.objects.bulk_update(
|
||||
issues_to_update, ["archived_at"], batch_size=100
|
||||
)
|
||||
[
|
||||
@ -77,7 +77,7 @@ def archive_old_issues():
|
||||
current_instance=None,
|
||||
subscriber=False,
|
||||
)
|
||||
for issue in issues_to_update
|
||||
for issue in updated_issues
|
||||
]
|
||||
return
|
||||
except Exception as e:
|
||||
@ -136,7 +136,7 @@ def close_old_issues():
|
||||
issues_to_update.append(issue)
|
||||
|
||||
# Bulk Update the issues and log the activity
|
||||
Issue.objects.bulk_update(issues_to_update, ["state"], batch_size=100)
|
||||
updated_issues = Issue.objects.bulk_update(issues_to_update, ["state"], batch_size=100)
|
||||
[
|
||||
issue_activity.delay(
|
||||
type="issue.activity.updated",
|
||||
@ -147,7 +147,7 @@ def close_old_issues():
|
||||
current_instance=None,
|
||||
subscriber=False,
|
||||
)
|
||||
for issue in issues_to_update
|
||||
for issue in updated_issues
|
||||
]
|
||||
return
|
||||
except Exception as e:
|
||||
|
Loading…
Reference in New Issue
Block a user