Make audit entries configurable

This commit is contained in:
Andrew 2022-01-31 17:58:02 -05:00
parent 3995560ba2
commit 2e96c40d62
2 changed files with 5 additions and 3 deletions

View File

@ -191,11 +191,11 @@ class helpers_management:
Audit_Log.log_msg: audit_msg, Audit_Log.log_msg: audit_msg,
Audit_Log.source_ip: source_ip Audit_Log.source_ip: source_ip
}).execute() }).execute()
#todo make this user configurable
#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:
if Audit_Log.select().count() > 300: #configurable through app/config/config.json
if Audit_Log.select().count() > helper.get_setting('max_audit_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
@ -212,7 +212,8 @@ 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:
if Audit_Log.select().count() > 300: #configurable through app/config/config.json
if Audit_Log.select().count() > helper.get_setting('max_audit_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

View File

@ -13,6 +13,7 @@
"show_contribute_link": true, "show_contribute_link": true,
"virtual_terminal_lines": 70, "virtual_terminal_lines": 70,
"max_log_lines": 700, "max_log_lines": 700,
"max_audit_entries": 300,
"keywords": ["help", "chunk"], "keywords": ["help", "chunk"],
"allow_nsfw_profile_pictures": false "allow_nsfw_profile_pictures": false
} }