{ "issue": { "url": "https://api.github.com/repos/laurent22/joplin/issues/11372", "repository_url": "https://api.github.com/repos/laurent22/joplin", "labels_url": "https://api.github.com/repos/laurent22/joplin/issues/11372/labels{/name}", "comments_url": "https://api.github.com/repos/laurent22/joplin/issues/11372/comments", "events_url": "https://api.github.com/repos/laurent22/joplin/issues/11372/events", "html_url": "https://github.com/laurent22/joplin/pull/11372", "id": 2647866401, "node_id": "PR_kwDOBLftOs6Bch0k", "number": 11372, "title": "Server: Resolves #9931: Add task to delete events older than a week", "user": { "login": "AdrienPoupa", "id": 15086425, "node_id": "MDQ6VXNlcjE1MDg2NDI1", "avatar_url": "https://avatars.githubusercontent.com/u/15086425?v=4", "gravatar_id": "", "url": "https://api.github.com/users/AdrienPoupa", "html_url": "https://github.com/AdrienPoupa", "followers_url": "https://api.github.com/users/AdrienPoupa/followers", "following_url": "https://api.github.com/users/AdrienPoupa/following{/other_user}", "gists_url": "https://api.github.com/users/AdrienPoupa/gists{/gist_id}", "starred_url": "https://api.github.com/users/AdrienPoupa/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/AdrienPoupa/subscriptions", "organizations_url": "https://api.github.com/users/AdrienPoupa/orgs", "repos_url": "https://api.github.com/users/AdrienPoupa/repos", "events_url": "https://api.github.com/users/AdrienPoupa/events{/privacy}", "received_events_url": "https://api.github.com/users/AdrienPoupa/received_events", "type": "User", "user_view_type": "public", "site_admin": false }, "labels": [], "state": "closed", "locked": false, "assignee": null, "assignees": [], "milestone": null, "comments": 8, "created_at": "2024-11-11T01:14:39Z", "updated_at": "2025-01-15T20:43:28Z", "closed_at": "2024-12-09T15:48:21Z", "author_association": "CONTRIBUTOR", "active_lock_reason": null, "draft": false, "pull_request": { "url": "https://api.github.com/repos/laurent22/joplin/pulls/11372", "html_url": "https://github.com/laurent22/joplin/pull/11372", "diff_url": "https://github.com/laurent22/joplin/pull/11372.diff", "patch_url": "https://github.com/laurent22/joplin/pull/11372.patch", "merged_at": "2024-12-09T15:48:21Z" }, "body": "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...).\r\n\r\nI'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).\r\n\r\nI also handled Laurent's review to use fake timers for the test.", "closed_by": { "login": "laurent22", "id": 1285584, "node_id": "MDQ6VXNlcjEyODU1ODQ=", "avatar_url": "https://avatars.githubusercontent.com/u/1285584?v=4", "gravatar_id": "", "url": "https://api.github.com/users/laurent22", "html_url": "https://github.com/laurent22", "followers_url": "https://api.github.com/users/laurent22/followers", "following_url": "https://api.github.com/users/laurent22/following{/other_user}", "gists_url": "https://api.github.com/users/laurent22/gists{/gist_id}", "starred_url": "https://api.github.com/users/laurent22/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/laurent22/subscriptions", "organizations_url": "https://api.github.com/users/laurent22/orgs", "repos_url": "https://api.github.com/users/laurent22/repos", "events_url": "https://api.github.com/users/laurent22/events{/privacy}", "received_events_url": "https://api.github.com/users/laurent22/received_events", "type": "User", "user_view_type": "public", "site_admin": false }, "reactions": { "url": "https://api.github.com/repos/laurent22/joplin/issues/11372/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 }, "timeline_url": "https://api.github.com/repos/laurent22/joplin/issues/11372/timeline", "performed_via_github_app": null, "state_reason": null }, "comments": [ { "url": "https://api.github.com/repos/laurent22/joplin/issues/comments/2467048300", "html_url": "https://github.com/laurent22/joplin/pull/11372#issuecomment-2467048300", "issue_url": "https://api.github.com/repos/laurent22/joplin/issues/11372", "id": 2467048300, "node_id": "IC_kwDOBLftOs6TDCts", "user": { "login": "github-actions[bot]", "id": 41898282, "node_id": "MDM6Qm90NDE4OTgyODI=", "avatar_url": "https://avatars.githubusercontent.com/in/15368?v=4", "gravatar_id": "", "url": "https://api.github.com/users/github-actions%5Bbot%5D", "html_url": "https://github.com/apps/github-actions", "followers_url": "https://api.github.com/users/github-actions%5Bbot%5D/followers", "following_url": "https://api.github.com/users/github-actions%5Bbot%5D/following{/other_user}", "gists_url": "https://api.github.com/users/github-actions%5Bbot%5D/gists{/gist_id}", "starred_url": "https://api.github.com/users/github-actions%5Bbot%5D/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/github-actions%5Bbot%5D/subscriptions", "organizations_url": "https://api.github.com/users/github-actions%5Bbot%5D/orgs", "repos_url": "https://api.github.com/users/github-actions%5Bbot%5D/repos", "events_url": "https://api.github.com/users/github-actions%5Bbot%5D/events{/privacy}", "received_events_url": "https://api.github.com/users/github-actions%5Bbot%5D/received_events", "type": "Bot", "user_view_type": "public", "site_admin": false }, "created_at": "2024-11-11T01:14:52Z", "updated_at": "2024-12-09T15:48:38Z", "author_association": "CONTRIBUTOR", "body": "****CLA Assistant Lite bot**** All contributors have signed the CLA ✍️ ✅", "reactions": { "url": "https://api.github.com/repos/laurent22/joplin/issues/comments/2467048300/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 }, "performed_via_github_app": { "id": 15368, "client_id": "Iv1.05c79e9ad1f6bdfa", "slug": "github-actions", "node_id": "MDM6QXBwMTUzNjg=", "owner": { "login": "github", "id": 9919, "node_id": "MDEyOk9yZ2FuaXphdGlvbjk5MTk=", "avatar_url": "https://avatars.githubusercontent.com/u/9919?v=4", "gravatar_id": "", "url": "https://api.github.com/users/github", "html_url": "https://github.com/github", "followers_url": "https://api.github.com/users/github/followers", "following_url": "https://api.github.com/users/github/following{/other_user}", "gists_url": "https://api.github.com/users/github/gists{/gist_id}", "starred_url": "https://api.github.com/users/github/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/github/subscriptions", "organizations_url": "https://api.github.com/users/github/orgs", "repos_url": "https://api.github.com/users/github/repos", "events_url": "https://api.github.com/users/github/events{/privacy}", "received_events_url": "https://api.github.com/users/github/received_events", "type": "Organization", "user_view_type": "public", "site_admin": false }, "name": "GitHub Actions", "description": "Automate your workflow from idea to production", "external_url": "https://help.github.com/en/actions", "html_url": "https://github.com/apps/github-actions", "created_at": "2018-07-30T09:30:17Z", "updated_at": "2025-03-07T16:35:00Z", "permissions": { "actions": "write", "administration": "read", "attestations": "write", "checks": "write", "contents": "write", "deployments": "write", "discussions": "write", "issues": "write", "merge_queues": "write", "metadata": "read", "models": "read", "packages": "write", "pages": "write", "pull_requests": "write", "repository_hooks": "write", "repository_projects": "write", "security_events": "write", "statuses": "write", "vulnerability_alerts": "read" }, "events": [ "branch_protection_rule", "check_run", "check_suite", "create", "delete", "deployment", "deployment_status", "discussion", "discussion_comment", "fork", "gollum", "issues", "issue_comment", "label", "merge_group", "milestone", "page_build", "project", "project_card", "project_column", "public", "pull_request", "pull_request_review", "pull_request_review_comment", "push", "registry_package", "release", "repository", "repository_dispatch", "status", "watch", "workflow_dispatch", "workflow_run" ] } }, { "url": "https://api.github.com/repos/laurent22/joplin/issues/comments/2467048814", "html_url": "https://github.com/laurent22/joplin/pull/11372#issuecomment-2467048814", "issue_url": "https://api.github.com/repos/laurent22/joplin/issues/11372", "id": 2467048814, "node_id": "IC_kwDOBLftOs6TDC1u", "user": { "login": "AdrienPoupa", "id": 15086425, "node_id": "MDQ6VXNlcjE1MDg2NDI1", "avatar_url": "https://avatars.githubusercontent.com/u/15086425?v=4", "gravatar_id": "", "url": "https://api.github.com/users/AdrienPoupa", "html_url": "https://github.com/AdrienPoupa", "followers_url": "https://api.github.com/users/AdrienPoupa/followers", "following_url": "https://api.github.com/users/AdrienPoupa/following{/other_user}", "gists_url": "https://api.github.com/users/AdrienPoupa/gists{/gist_id}", "starred_url": "https://api.github.com/users/AdrienPoupa/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/AdrienPoupa/subscriptions", "organizations_url": "https://api.github.com/users/AdrienPoupa/orgs", "repos_url": "https://api.github.com/users/AdrienPoupa/repos", "events_url": "https://api.github.com/users/AdrienPoupa/events{/privacy}", "received_events_url": "https://api.github.com/users/AdrienPoupa/received_events", "type": "User", "user_view_type": "public", "site_admin": false }, "created_at": "2024-11-11T01:15:35Z", "updated_at": "2024-11-11T01:15:35Z", "author_association": "CONTRIBUTOR", "body": "I have read the CLA Document and I hereby sign the CLA", "reactions": { "url": "https://api.github.com/repos/laurent22/joplin/issues/comments/2467048814/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 }, "performed_via_github_app": null }, { "url": "https://api.github.com/repos/laurent22/joplin/issues/comments/2468481664", "html_url": "https://github.com/laurent22/joplin/pull/11372#issuecomment-2468481664", "issue_url": "https://api.github.com/repos/laurent22/joplin/issues/11372", "id": 2468481664, "node_id": "IC_kwDOBLftOs6TIgqA", "user": { "login": "AdrienPoupa", "id": 15086425, "node_id": "MDQ6VXNlcjE1MDg2NDI1", "avatar_url": "https://avatars.githubusercontent.com/u/15086425?v=4", "gravatar_id": "", "url": "https://api.github.com/users/AdrienPoupa", "html_url": "https://github.com/AdrienPoupa", "followers_url": "https://api.github.com/users/AdrienPoupa/followers", "following_url": "https://api.github.com/users/AdrienPoupa/following{/other_user}", "gists_url": "https://api.github.com/users/AdrienPoupa/gists{/gist_id}", "starred_url": "https://api.github.com/users/AdrienPoupa/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/AdrienPoupa/subscriptions", "organizations_url": "https://api.github.com/users/AdrienPoupa/orgs", "repos_url": "https://api.github.com/users/AdrienPoupa/repos", "events_url": "https://api.github.com/users/AdrienPoupa/events{/privacy}", "received_events_url": "https://api.github.com/users/AdrienPoupa/received_events", "type": "User", "user_view_type": "public", "site_admin": false }, "created_at": "2024-11-11T15:45:32Z", "updated_at": "2024-11-11T15:46:46Z", "author_association": "CONTRIBUTOR", "body": "Hi Laurent, thanks for the review.\r\n\r\n> The TTL should be configurable via an env variable\r\n\r\nWhat would we gain from this? The `DeleteExpiredTokens` task that I'm using as a reference does not have this logic. \r\n\r\nIf we need to implement it, do you have a preferred approach? I see the `UserDeletionService` uses the `USER_DATA_AUTO_DELETE_AFTER_DAYS` environment variable, I could use the same mechanism.\r\n\r\n> What's the impact of deleting old events - what service or function could be affected by it?\r\n\r\nI don't know, sorry. It is the approach you suggested here however: https://github.com/laurent22/joplin/issues/9931#issuecomment-1941780582", "reactions": { "url": "https://api.github.com/repos/laurent22/joplin/issues/comments/2468481664/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 }, "performed_via_github_app": null }, { "url": "https://api.github.com/repos/laurent22/joplin/issues/comments/2468811114", "html_url": "https://github.com/laurent22/joplin/pull/11372#issuecomment-2468811114", "issue_url": "https://api.github.com/repos/laurent22/joplin/issues/11372", "id": 2468811114, "node_id": "IC_kwDOBLftOs6TJxFq", "user": { "login": "laurent22", "id": 1285584, "node_id": "MDQ6VXNlcjEyODU1ODQ=", "avatar_url": "https://avatars.githubusercontent.com/u/1285584?v=4", "gravatar_id": "", "url": "https://api.github.com/users/laurent22", "html_url": "https://github.com/laurent22", "followers_url": "https://api.github.com/users/laurent22/followers", "following_url": "https://api.github.com/users/laurent22/following{/other_user}", "gists_url": "https://api.github.com/users/laurent22/gists{/gist_id}", "starred_url": "https://api.github.com/users/laurent22/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/laurent22/subscriptions", "organizations_url": "https://api.github.com/users/laurent22/orgs", "repos_url": "https://api.github.com/users/laurent22/repos", "events_url": "https://api.github.com/users/laurent22/events{/privacy}", "received_events_url": "https://api.github.com/users/laurent22/received_events", "type": "User", "user_view_type": "public", "site_admin": false }, "created_at": "2024-11-11T18:39:56Z", "updated_at": "2024-11-11T18:39:56Z", "author_association": "OWNER", "body": "> What would we gain from this? \r\n\r\nFor audit purposes for example.\r\n\r\n> I don't know, sorry. It is the approach you suggested here however: [#9931 (comment)](https://github.com/laurent22/joplin/issues/9931#issuecomment-1941780582)\r\n\r\nIf you can check please post here", "reactions": { "url": "https://api.github.com/repos/laurent22/joplin/issues/comments/2468811114/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 }, "performed_via_github_app": null }, { "url": "https://api.github.com/repos/laurent22/joplin/issues/comments/2469373474", "html_url": "https://github.com/laurent22/joplin/pull/11372#issuecomment-2469373474", "issue_url": "https://api.github.com/repos/laurent22/joplin/issues/11372", "id": 2469373474, "node_id": "IC_kwDOBLftOs6TL6Yi", "user": { "login": "AdrienPoupa", "id": 15086425, "node_id": "MDQ6VXNlcjE1MDg2NDI1", "avatar_url": "https://avatars.githubusercontent.com/u/15086425?v=4", "gravatar_id": "", "url": "https://api.github.com/users/AdrienPoupa", "html_url": "https://github.com/AdrienPoupa", "followers_url": "https://api.github.com/users/AdrienPoupa/followers", "following_url": "https://api.github.com/users/AdrienPoupa/following{/other_user}", "gists_url": "https://api.github.com/users/AdrienPoupa/gists{/gist_id}", "starred_url": "https://api.github.com/users/AdrienPoupa/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/AdrienPoupa/subscriptions", "organizations_url": "https://api.github.com/users/AdrienPoupa/orgs", "repos_url": "https://api.github.com/users/AdrienPoupa/repos", "events_url": "https://api.github.com/users/AdrienPoupa/events{/privacy}", "received_events_url": "https://api.github.com/users/AdrienPoupa/received_events", "type": "User", "user_view_type": "public", "site_admin": false }, "created_at": "2024-11-12T00:58:50Z", "updated_at": "2024-11-12T00:58:50Z", "author_association": "CONTRIBUTOR", "body": "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:\r\n```\r\nawait this.models.event().create(EventType.TaskStarted, id.toString());\r\n```\r\nand\r\n```\r\nawait this.models.event().create(EventType.TaskCompleted, id.toString());\r\n```\r\n\r\nIn `taskLastEvents`, we retrieve the last events for a given task:\r\n\r\n```\r\n\tpublic async taskLastEvents(id: TaskId): Promise {\r\n\t\treturn {\r\n\t\t\ttaskStarted: await this.models.event().lastEventByTypeAndName(EventType.TaskStarted, id.toString()),\r\n\t\t\ttaskCompleted: await this.models.event().lastEventByTypeAndName(EventType.TaskCompleted, id.toString()),\r\n\t\t};\r\n\t}\r\n```\r\n\r\nThis function, in turn, is used in the `admin/tasks` route to show task events (columns `Last Run` and `Last Completion`).\r\n\r\nThose 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.", "reactions": { "url": "https://api.github.com/repos/laurent22/joplin/issues/comments/2469373474/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 }, "performed_via_github_app": null }, { "url": "https://api.github.com/repos/laurent22/joplin/issues/comments/2469427219", "html_url": "https://github.com/laurent22/joplin/pull/11372#issuecomment-2469427219", "issue_url": "https://api.github.com/repos/laurent22/joplin/issues/11372", "id": 2469427219, "node_id": "IC_kwDOBLftOs6TMHgT", "user": { "login": "AdrienPoupa", "id": 15086425, "node_id": "MDQ6VXNlcjE1MDg2NDI1", "avatar_url": "https://avatars.githubusercontent.com/u/15086425?v=4", "gravatar_id": "", "url": "https://api.github.com/users/AdrienPoupa", "html_url": "https://github.com/AdrienPoupa", "followers_url": "https://api.github.com/users/AdrienPoupa/followers", "following_url": "https://api.github.com/users/AdrienPoupa/following{/other_user}", "gists_url": "https://api.github.com/users/AdrienPoupa/gists{/gist_id}", "starred_url": "https://api.github.com/users/AdrienPoupa/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/AdrienPoupa/subscriptions", "organizations_url": "https://api.github.com/users/AdrienPoupa/orgs", "repos_url": "https://api.github.com/users/AdrienPoupa/repos", "events_url": "https://api.github.com/users/AdrienPoupa/events{/privacy}", "received_events_url": "https://api.github.com/users/AdrienPoupa/received_events", "type": "User", "user_view_type": "public", "site_admin": false }, "created_at": "2024-11-12T01:48:15Z", "updated_at": "2024-11-12T01:48:15Z", "author_association": "CONTRIBUTOR", "body": "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 :)", "reactions": { "url": "https://api.github.com/repos/laurent22/joplin/issues/comments/2469427219/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 }, "performed_via_github_app": null }, { "url": "https://api.github.com/repos/laurent22/joplin/issues/comments/2480835121", "html_url": "https://github.com/laurent22/joplin/pull/11372#issuecomment-2480835121", "issue_url": "https://api.github.com/repos/laurent22/joplin/issues/11372", "id": 2480835121, "node_id": "IC_kwDOBLftOs6T3oox", "user": { "login": "AdrienPoupa", "id": 15086425, "node_id": "MDQ6VXNlcjE1MDg2NDI1", "avatar_url": "https://avatars.githubusercontent.com/u/15086425?v=4", "gravatar_id": "", "url": "https://api.github.com/users/AdrienPoupa", "html_url": "https://github.com/AdrienPoupa", "followers_url": "https://api.github.com/users/AdrienPoupa/followers", "following_url": "https://api.github.com/users/AdrienPoupa/following{/other_user}", "gists_url": "https://api.github.com/users/AdrienPoupa/gists{/gist_id}", "starred_url": "https://api.github.com/users/AdrienPoupa/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/AdrienPoupa/subscriptions", "organizations_url": "https://api.github.com/users/AdrienPoupa/orgs", "repos_url": "https://api.github.com/users/AdrienPoupa/repos", "events_url": "https://api.github.com/users/AdrienPoupa/events{/privacy}", "received_events_url": "https://api.github.com/users/AdrienPoupa/received_events", "type": "User", "user_view_type": "public", "site_admin": false }, "created_at": "2024-11-16T22:40:28Z", "updated_at": "2024-11-16T22:40:28Z", "author_association": "CONTRIBUTOR", "body": "> What's the meaning of setting EVENTS_AUTO_DELETE_AFTER_DAYS to 0? It deletes everything immediately?\r\n\r\nIt will delete events older than the current timestamp, so yes. I don't think that's an issue given you'd have to go ahead and actively set the config as such.", "reactions": { "url": "https://api.github.com/repos/laurent22/joplin/issues/comments/2480835121/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 }, "performed_via_github_app": null }, { "url": "https://api.github.com/repos/laurent22/joplin/issues/comments/2593896192", "html_url": "https://github.com/laurent22/joplin/pull/11372#issuecomment-2593896192", "issue_url": "https://api.github.com/repos/laurent22/joplin/issues/11372", "id": 2593896192, "node_id": "IC_kwDOBLftOs6am7cA", "user": { "login": "ahayzen", "id": 3669750, "node_id": "MDQ6VXNlcjM2Njk3NTA=", "avatar_url": "https://avatars.githubusercontent.com/u/3669750?v=4", "gravatar_id": "", "url": "https://api.github.com/users/ahayzen", "html_url": "https://github.com/ahayzen", "followers_url": "https://api.github.com/users/ahayzen/followers", "following_url": "https://api.github.com/users/ahayzen/following{/other_user}", "gists_url": "https://api.github.com/users/ahayzen/gists{/gist_id}", "starred_url": "https://api.github.com/users/ahayzen/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/ahayzen/subscriptions", "organizations_url": "https://api.github.com/users/ahayzen/orgs", "repos_url": "https://api.github.com/users/ahayzen/repos", "events_url": "https://api.github.com/users/ahayzen/events{/privacy}", "received_events_url": "https://api.github.com/users/ahayzen/received_events", "type": "User", "user_view_type": "public", "site_admin": false }, "created_at": "2025-01-15T20:43:27Z", "updated_at": "2025-01-15T20:43:27Z", "author_association": "NONE", "body": "Is there a timeframe for when there be a tagged server release that includes this fix on docker hub ? As it would be great to make use of this change. https://hub.docker.com/r/joplin/server/tags", "reactions": { "url": "https://api.github.com/repos/laurent22/joplin/issues/comments/2593896192/reactions", "total_count": 2, "+1": 2, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 }, "performed_via_github_app": null } ] }