feat: allow auto clearing notificaiton log (#18344)

This commit is contained in:
Ankush Menat 2022-10-10 16:21:37 +05:30 committed by GitHub
parent 121a6e1108
commit 4020513712
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 0 deletions

View file

@ -20,6 +20,14 @@ class NotificationLog(Document):
except frappe.OutgoingEmailError:
self.log_error(_("Failed to send notification email"))
@staticmethod
def clear_old_logs(days=180):
from frappe.query_builder import Interval
from frappe.query_builder.functions import Now
table = frappe.qb.DocType("Notification Log")
frappe.db.delete(table, filters=(table.modified < (Now() - Interval(days=days))))
def get_permission_query_conditions(for_user):
if not for_user:

View file

@ -0,0 +1,7 @@
frappe.listview_settings["Notification Log"] = {
onload: function (listview) {
frappe.require("logtypes.bundle.js", () => {
frappe.utils.logtypes.show_log_retention_message(cur_list.doctype);
});
},
};