joplin icon indicating copy to clipboard operation
joplin copied to clipboard

Server: Fixes #9931: Add task to delete events older than a week

Open tecc opened this issue 1 year ago • 3 comments

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');
}

tecc avatar Feb 23 '24 20:02 tecc

CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅

github-actions[bot] avatar Feb 23 '24 20:02 github-actions[bot]

I have read the CLA Document and I hereby sign the CLA

tecc avatar Feb 23 '24 21:02 tecc

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 avatar Feb 24 '24 15:02 tecc

@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.

laurent22 avatar Mar 09 '24 10:03 laurent22

@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!

rainforest1155 avatar Apr 09 '24 07:04 rainforest1155