瀏覽代碼

Enqueued communication patch if more than 1 lakh records

version-14
Nabin Hait 7 年之前
父節點
當前提交
8463937acd
共有 1 個檔案被更改,包括 9 行新增1 行删除
  1. +9
    -1
      frappe/patches/v9_1/move_feed_to_activity_log.py

+ 9
- 1
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")

Loading…
取消
儲存