Possible to auto clear logs older than a certain amount of time?
mibby opened this issue ยท 4 comments
Is it possible to auto clear logs in the database after a certain amount of time to avoid the database from eventually being flooded with old information?
I'm assuming when a user checks their sales history since last checked, it removes / clears the logs from the database automatically. (If not, there should be an option for it to do so!) I'd like to be able to auto-clear all logs older than 30 days for things not removed and for users that have shops but haven't logged in in a long time. Similar to logblock's database purging at server start-up.
Hm, I thought a bit about the /csn clear
behaviour and would propose a new command, /csn read
that marks the history entries as read (like /csn clear
currently does interally) but still displays them in /csn history
(maybe with a different color). /csn clear
should then actually remove all the notifications from the database and maybe get some parameters to specify which timeframe it should clear. E.g /csn clear all
, /csn clear before 7 days
or /csn clear last 10
.
For the autoclear I could implement something like /csn globalclear
which could take similar parameters like the /csn clear
command or some kind of table size check on startup. Not sure about that yet as I prefer direct clearing of the database via cronjobs.
Sounds good to me. :) Though I do like the idea of logs older than a certain amount of time being purged automatically at server start-up or every so often so you can avoid the database from being filled up over time from users who don't want to clear / don't have permission to clear and not worry about having to clear them yourself manually.
Logblock for example runs their 'clearlog' parameters at start-up and every defined time. Example of that setup.
clearlog:
auto:
- world "world" before 60 days all
- world "world_nether" before 60 days all
- world "world_the_end" before 60 days all
autoClearLogDelay: 6h
dumpDeletedLog: false
enableAutoClearLog: true
I added a /csn cleandatabase
command in e09dbbf which accepts some parameter like --before <days>
, --user <username|uuid>
, --unread
(default behaviour) and --all
. Currently there is no way to to automatically clean it in the plugin itself but that should help keeping the table more clean.
/csn clear
now also directly deletes unread entries from the database, opening /csn history
directly marks unread entries as read and still displays read entries in gray.
On second thought, I don't think /csn clear
is removing the logs from the database. Just marking them as read. This is a problem because you can't look-up old logs and the database contains old, outdated information that it no longer needs to store.
I still propose that /csn clear
deletes the logs from the database instead of marking them as read and have a config setting to periodically purge old records that weren't 'marked as red' but were left inactive for longer than a certain time.