Create fallback for audit entires

This commit is contained in:
Andrew 2022-01-31 18:09:23 -05:00
parent 2e96c40d62
commit 3e822ea076

View File

@ -194,8 +194,11 @@ class helpers_management:
#deletes records when they're more than 100 #deletes records when they're more than 100
ordered = Audit_Log.select().order_by(+Audit_Log.created) ordered = Audit_Log.select().order_by(+Audit_Log.created)
for item in ordered: for item in ordered:
#configurable through app/config/config.json if not helper.get_setting('max_audit_entries'):
if Audit_Log.select().count() > helper.get_setting('max_audit_entries'): max_entries = 300
else:
max_entries = helper.get_setting('max_audit_entries')
if Audit_Log.select().count() > max_entries:
Audit_Log.delete().where(Audit_Log.audit_id == item.audit_id).execute() Audit_Log.delete().where(Audit_Log.audit_id == item.audit_id).execute()
else: else:
return return
@ -213,7 +216,11 @@ class helpers_management:
ordered = Audit_Log.select().order_by(+Audit_Log.created) ordered = Audit_Log.select().order_by(+Audit_Log.created)
for item in ordered: for item in ordered:
#configurable through app/config/config.json #configurable through app/config/config.json
if Audit_Log.select().count() > helper.get_setting('max_audit_entries'): if not helper.get_setting('max_audit_entries'):
max_entries = 300
else:
max_entries = helper.get_setting('max_audit_entries')
if Audit_Log.select().count() > max_entries:
Audit_Log.delete().where(Audit_Log.audit_id == item.audit_id).execute() Audit_Log.delete().where(Audit_Log.audit_id == item.audit_id).execute()
else: else:
return return