mirror of
https://gitlab.com/crafty-controller/crafty-4.git
synced 2024-08-30 18:23:09 +00:00
Delete audit logs when they exceed 100 entries
This commit is contained in:
parent
8232a630ee
commit
7889ca3153
@ -191,6 +191,14 @@ class helpers_management:
|
||||
Audit_Log.log_msg: audit_msg,
|
||||
Audit_Log.source_ip: source_ip
|
||||
}).execute()
|
||||
#todo make this user configurable
|
||||
#deletes records when they're more than 100
|
||||
ordered = Audit_Log.select().order_by(+Audit_Log.created)
|
||||
for item in ordered:
|
||||
if Audit_Log.select().count() > 100:
|
||||
Audit_Log.delete().where(Audit_Log.audit_id == item.audit_id).execute()
|
||||
else:
|
||||
return
|
||||
|
||||
@staticmethod
|
||||
def add_to_audit_log_raw(user_name, user_id, server_id, log_msg, source_ip):
|
||||
@ -201,7 +209,13 @@ class helpers_management:
|
||||
Audit_Log.log_msg: log_msg,
|
||||
Audit_Log.source_ip: source_ip
|
||||
}).execute()
|
||||
|
||||
#deletes records when they're more than 100
|
||||
ordered = Audit_Log.select().order_by(+Audit_Log.created)
|
||||
for item in ordered:
|
||||
if Audit_Log.select().count() > 100:
|
||||
Audit_Log.delete().where(Audit_Log.audit_id == item.audit_id).execute()
|
||||
else:
|
||||
return
|
||||
#************************************************************************************************
|
||||
# Schedules Methods
|
||||
#************************************************************************************************
|
||||
|
Loading…
Reference in New Issue
Block a user