diff --git a/app/classes/models/management.py b/app/classes/models/management.py index 1dded136..91fb98db 100644 --- a/app/classes/models/management.py +++ b/app/classes/models/management.py @@ -192,6 +192,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() > 300: + 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): @@ -202,7 +210,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() > 300: + Audit_Log.delete().where(Audit_Log.audit_id == item.audit_id).execute() + else: + return #************************************************************************************************ # Schedules Methods #************************************************************************************************