joplin
joplin copied to clipboard
Server: Fixes #9931: Add task to delete events older than a week
This fixes #9931 through adding a task that deletes any tasks older than a week.
The task in question looks like this:
public async deleteOldEvents(beforeMillis: number = Date.now() - Week) {
return this.withTransaction(async () => {
await this.db(this.tableName)
.where('created_time', '<', beforeMillis)
.delete();
}, 'EventModel::deleteOldEvents');
}
CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅
I have read the CLA Document and I hereby sign the CLA
Added a test for it, although as a side effect I felt it necessary to make created_time
a parameter.
Making created_time
a parameter makes it easier to control the timestamps of the events rather than haphazardly guessing them. The parameter could be used in the should get the latest event
test as well to speed it up ever so slightly.
@tecc, sorry I need to close this pull request since we're trying to keep the list of PR current. However if you would like to complete the pull request please let me know and I'll reopen.
@tecc Thank you for your work on this so far! I was wondering if you think you would be able to work on this again in the near future? I have about 210MB of data on my Joplin server right now, but the database dump amounts to almost 1000MB, which with my daily backup strategy does add up quite a bit. So I would love to have a clean up task in place as you proposed. Thanks!