From ff003da663ab77e808b34ff0a833770fed0d1a66 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Wed, 25 May 2016 10:35:29 +0530 Subject: [PATCH] [fix] bulk email indexing --- frappe/email/doctype/bulk_email/bulk_email.json | 9 ++++++--- frappe/email/doctype/bulk_email/bulk_email.py | 6 +++++- frappe/utils/error.py | 5 +++-- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/frappe/email/doctype/bulk_email/bulk_email.json b/frappe/email/doctype/bulk_email/bulk_email.json index 4fe5154d2a..94d4b259c4 100644 --- a/frappe/email/doctype/bulk_email/bulk_email.json +++ b/frappe/email/doctype/bulk_email/bulk_email.json @@ -3,6 +3,7 @@ "allow_import": 0, "allow_rename": 0, "autoname": "hash", + "beta": 0, "creation": "2012-08-02 15:17:28", "custom": 0, "description": "Bulk Email records.", @@ -106,7 +107,7 @@ "read_only": 0, "report_hide": 0, "reqd": 0, - "search_index": 0, + "search_index": 1, "set_only_once": 0, "unique": 0 }, @@ -271,7 +272,7 @@ "issingle": 0, "istable": 0, "max_attachments": 0, - "modified": "2016-04-18 05:13:07.741981", + "modified": "2016-05-25 10:33:47.439401", "modified_by": "Administrator", "module": "Email", "name": "Bulk Email", @@ -298,7 +299,9 @@ "write": 0 } ], + "quick_entry": 0, "read_only": 0, "read_only_onload": 0, - "sort_order": "DESC" + "sort_order": "DESC", + "track_seen": 0 } \ No newline at end of file diff --git a/frappe/email/doctype/bulk_email/bulk_email.py b/frappe/email/doctype/bulk_email/bulk_email.py index 4adfade31a..256c80a80e 100644 --- a/frappe/email/doctype/bulk_email/bulk_email.py +++ b/frappe/email/doctype/bulk_email/bulk_email.py @@ -20,4 +20,8 @@ def retry_sending(name): @frappe.whitelist() def send_now(name): doc = frappe.get_doc("Bulk Email", name) - send_one(doc, now=True) \ No newline at end of file + send_one(doc, now=True) + +def on_doctype_update(): + """Add index in `tabCommunication` for `(reference_doctype, reference_name)`""" + frappe.db.add_index("Bulk Email", ["creation"]) diff --git a/frappe/utils/error.py b/frappe/utils/error.py index 19a113dede..3b13f2e7fc 100644 --- a/frappe/utils/error.py +++ b/frappe/utils/error.py @@ -192,9 +192,10 @@ def clear_old_snapshots(): today = datetime.datetime.now() for file in os.listdir(path): - ctime = datetime.datetime.fromtimestamp(os.path.getctime(file)) + p = os.path.join(path, file) + ctime = datetime.datetime.fromtimestamp(os.path.getctime(p)) if (today - ctime).days > 31: - os.remove(os.path.join(path, file)) + os.remove(os.path.join(path, p)) def get_error_snapshot_path(): return frappe.get_site_path('error-snapshots')