fix: fixed sider issues

This commit is contained in:
Aradhya-Tripathi 2021-10-14 23:25:43 +05:30
parent 668051cfe9
commit 4ed10de918
2 changed files with 7 additions and 5 deletions

View file

@ -7,6 +7,8 @@ from frappe.utils import get_fullname, now
from frappe.model.document import Document
from frappe.core.utils import set_timeline_doc
import frappe
from frappe.query_builder import DocType, Interval
from frappe.query_builder.functions import Now
class ActivityLog(Document):
def before_insert(self):
@ -44,6 +46,7 @@ def clear_activity_logs(days=None):
if not days:
days = 90
frappe.db.sql("""delete from `tabActivity Log` where \
creation< (NOW() - INTERVAL '{0}' DAY)""".format(days))
doctype = DocType("Activity Log")
frappe.qb.from_(doctype).where(
doctype.creation < (Now() - Interval(days=days))
).delete().run()

View file

@ -64,8 +64,7 @@ def get_sessions_to_clear(user=None, keep_current=False, device=None):
offset = simultaneous_sessions - 1
table = frappe.qb.DocType("Sessions")
criterion = frappe.qb.from_(table).where(table.user == user) \
.where(table.device.isin(device))
criterion = frappe.qb.from_(table).where((table.user == user) & (table.device.isin(device)))
if keep_current:
criterion = criterion.where(table.sid != frappe.db.escape(frappe.session.sid))