-
-
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: Resolves #9931: Add task to delete events older than a week #11372
base: dev
Are you sure you want to change the base?
Conversation
CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅ |
I have read the CLA Document and I hereby sign the CLA |
0ada87b
to
1d3dfca
Compare
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.
Thanks for looking into this. I think there's two issues:
- The TTL should be configurable via an env variable
- What's the impact of deleting old events - what service or function could be affected by it?
@@ -4,6 +4,8 @@ import BaseModel, { UuidType } from './BaseModel'; | |||
|
|||
export default class EventModel extends BaseModel<Event> { | |||
|
|||
private eventTtl_: number = 7 * 24 * 60 * 60 * 1000; |
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.
7 * Day
is clearer (import the Day constant)
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.
I was using TokenModel as a reference that has the exact same line. I changed it there as well.
} | ||
|
||
jest.useRealTimers(); | ||
}); |
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 possible please also add another for:
- When there's 0 event in the database
- When the TTL means no event would be deleted
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.
Sure, done.
Hi Laurent, thanks for the review.
What would we gain from this? The If we need to implement it, do you have a preferred approach? I see the
I don't know, sorry. It is the approach you suggested here however: #9931 (comment) |
For audit purposes for example.
If you can check please post here |
I analyzed events and their usages, I found that we're creating events in TaskService's runTask just before and after the task is handled:
and
In
This function, in turn, is used in the Those were the only usages I could find, so they're here for auditing/debugging purposes, they have no impact on the behaviour of the application. |
I added two environment variables to enable the deletion and control the cut off period, and improved the test coverage. Hopefully that should do it :) |
a796af6
to
c32076b
Compare
Revisiting https://github.com/laurent22/joplin/pull/9988/files as I had the same issue this week (my Joplin DB grew to 600mb while I only have a few notes...).
I'm using mostly the same code, but I tried to match other patterns found in the codebase (using a TTL attribute in the class, not requiring arguments in the event function).
I also handled Laurent's review to use fake timers for the test.