-
-
Notifications
You must be signed in to change notification settings - Fork 5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Server: Fixes #9931: Add task to delete events older than a week #9988
Conversation
|
CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅ |
|
I have read the CLA Document and I hereby sign the CLA |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If something is batch deleting data, surely we need some tests too.
| @@ -33,4 +34,11 @@ export default class EventModel extends BaseModel<Event> { | |||
| .first(); | |||
| } | |||
|
|
|||
| public async deleteOldEvents(beforeMillis: number = Date.now() - Week) { | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All time should be milliseconds so there's no need to append a suffix. It's only in the rare case when it's not milliseconds that we append one.
No need for the weird default argument value, please make it required.
…Millis`, change `beforeMillis` to `before`
…as an optional parameter to `EventModel::create`
|
Added a test for it, although as a side effect I felt it necessary to make |
…ter-deletion check, forgotten negative sign
| @@ -16,11 +15,11 @@ export default class EventModel extends BaseModel<Event> { | |||
| return UuidType.Native; | |||
| } | |||
|
|
|||
| public async create(type: EventType, name = '') { | |||
| public async create(type: EventType, name = '', created_time = Date.now()) { | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not necessary and should be avoided. Instead you can use this in the test to simulate time:
jest
.useFakeTimers()
.setSystemTime(new Date('2020-01-01'));
See here for more information: https://stackoverflow.com/a/63377110/561309
|
@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. |
This fixes #9931 through adding a task that deletes any tasks older than a week.
The task in question looks like this: