From 0d8d5b522c70a015b8ddf99874894d282fc2fe12 Mon Sep 17 00:00:00 2001 From: Ankush Menat Date: Sun, 12 Jun 2022 22:03:34 +0530 Subject: [PATCH] feat: log clearing support --- .../ecommerce_integration_log.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/ecommerce_integrations/ecommerce_integrations/doctype/ecommerce_integration_log/ecommerce_integration_log.py b/ecommerce_integrations/ecommerce_integrations/doctype/ecommerce_integration_log/ecommerce_integration_log.py index 54517501..94ab25e4 100644 --- a/ecommerce_integrations/ecommerce_integrations/doctype/ecommerce_integration_log/ecommerce_integration_log.py +++ b/ecommerce_integrations/ecommerce_integrations/doctype/ecommerce_integration_log/ecommerce_integration_log.py @@ -6,6 +6,8 @@ import frappe from frappe import _ from frappe.model.document import Document +from frappe.query_builder import Interval +from frappe.query_builder.functions import Now from frappe.utils import strip_html from frappe.utils.data import cstr @@ -27,6 +29,13 @@ def _set_title(self): title = strip_html(title) self.title = title if len(title) < 100 else title[:100] + "..." + @staticmethod + def clear_old_logs(days=90): + table = frappe.qb.DocType("Ecommerce Integration Log") + frappe.db.delete( + table, filters=((table.modified < (Now() - Interval(days=days)))) & (table.status == "Success") + ) + def create_log( module_def=None,