Skip to content

Commit

Permalink
refactor: use sql to clear comments
Browse files Browse the repository at this point in the history
  • Loading branch information
ruthra-kumar committed Mar 28, 2024
1 parent 6b2f745 commit 1f46c15
Showing 1 changed file with 5 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -414,17 +414,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 1f46c15

Please sign in to comment.