Skip to content

Commit

Permalink
Merge pull request #40747 from frappe/mergify/bp/version-14/pr-40739
Browse files Browse the repository at this point in the history
refactor: use sql to clear comments (backport #40739)
  • Loading branch information
ruthra-kumar authored Mar 29, 2024
2 parents 5827bdc + 0322c1a commit db56d25
Showing 1 changed file with 5 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -388,17 +388,11 @@ def delete_communications(self, doctype, reference_doc_names):
frappe.delete_doc("Communication", batch, ignore_permissions=True)

def delete_comments(self, doctype, reference_doc_names):
comments = frappe.get_all(
"Comment",
filters={"reference_doctype": doctype, "reference_name": ["in", reference_doc_names]},
)
comment_names = [c.name for c in comments]

if not comment_names:
return

for batch in create_batch(comment_names, self.batch_size):
frappe.delete_doc("Comment", batch, ignore_permissions=True)
if reference_doc_names:
comment = qb.DocType("Comment")
qb.from_(comment).delete().where(
(comment.reference_doctype == doctype) & (comment.reference_name.isin(reference_doc_names))
).run()

def unlink_attachments(self, doctype, reference_doc_names):
files = frappe.get_all(
Expand Down

0 comments on commit db56d25

Please sign in to comment.