fix: clean up logs job was broken

This commit is contained in:
shadrak gurupnor 2022-02-24 09:49:43 +05:30
parent c332254688
commit c2c858f70e
3 changed files with 5 additions and 3 deletions

View file

@ -48,6 +48,7 @@ def clear_activity_logs(days=None):
if not days:
days = 90
doctype = DocType("Activity Log")
duration = (Now() - Interval(days=days))
frappe.db.delete(doctype, filters=(
doctype.creation < PseudoColumn(f"({Now() - Interval(days=days)})")
doctype.creation < duration
))

View file

@ -18,8 +18,9 @@ class LogSettings(Document):
def clear_error_logs(self):
table = DocType("Error Log")
duration = (Now() - Interval(days=self.clear_error_log_after))
frappe.db.delete(table, filters=(
table.creation < PseudoColumn(f"({Now() - Interval(days=self.clear_error_log_after)})")
table.creation < duration
))
def clear_activity_logs(self):

View file

@ -170,7 +170,7 @@ def clear_outbox(days=None):
days=31
email_queues = frappe.db.sql_list("""SELECT `name` FROM `tabEmail Queue`
WHERE `priority`=0 AND `modified` < (NOW() - INTERVAL '{0}' DAY)""".format(days))
WHERE `modified` < (NOW() - INTERVAL '{0}' DAY)""".format(days))
if email_queues:
frappe.db.delete("Email Queue", {"name": ("in", email_queues)})