diff --git a/frappe/patches/v9_1/move_feed_to_activity_log.py b/frappe/patches/v9_1/move_feed_to_activity_log.py index d1d491b90c..2d35e1e908 100644 --- a/frappe/patches/v9_1/move_feed_to_activity_log.py +++ b/frappe/patches/v9_1/move_feed_to_activity_log.py @@ -1,6 +1,14 @@ import frappe +from frappe.utils.background_jobs import enqueue def execute(): + comm_records_count = frappe.db.count("Communication", {"comment_type": "Updated"}) + if comm_records_count > 100000: + enqueue(method=move_data_from_communication_to_activity_log, queue='short', now=True) + else: + move_data_from_communication_to_activity_log() + +def move_data_from_communication_to_activity_log(): frappe.reload_doc("core", "doctype", "communication") frappe.reload_doc("core", "doctype", "activity_log") @@ -12,4 +20,4 @@ def execute(): where comment_type = 'Updated'""") frappe.db.sql("""delete from `tabCommunication` where comment_type = 'Updated'""") - frappe.delete_doc("DocType", "Authentication Log") + frappe.delete_doc("DocType", "Authentication Log") \ No newline at end of file