{ "issue": { "url": "https://api.github.com/repos/laurent22/joplin/issues/8746", "repository_url": "https://api.github.com/repos/laurent22/joplin", "labels_url": "https://api.github.com/repos/laurent22/joplin/issues/8746/labels{/name}", "comments_url": "https://api.github.com/repos/laurent22/joplin/issues/8746/comments", "events_url": "https://api.github.com/repos/laurent22/joplin/issues/8746/events", "html_url": "https://github.com/laurent22/joplin/pull/8746", "id": 1870996492, "node_id": "PR_kwDOBLftOs5Y__uD", "number": 8746, "title": "Desktop: Fixes #8653: Remove tags from DB once tag is orphaned", "user": { "login": "CptMeetKat", "id": 32354598, "node_id": "MDQ6VXNlcjMyMzU0NTk4", "avatar_url": "https://avatars.githubusercontent.com/u/32354598?v=4", "gravatar_id": "", "url": "https://api.github.com/users/CptMeetKat", "html_url": "https://github.com/CptMeetKat", "followers_url": "https://api.github.com/users/CptMeetKat/followers", "following_url": "https://api.github.com/users/CptMeetKat/following{/other_user}", "gists_url": "https://api.github.com/users/CptMeetKat/gists{/gist_id}", "starred_url": "https://api.github.com/users/CptMeetKat/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/CptMeetKat/subscriptions", "organizations_url": "https://api.github.com/users/CptMeetKat/orgs", "repos_url": "https://api.github.com/users/CptMeetKat/repos", "events_url": "https://api.github.com/users/CptMeetKat/events{/privacy}", "received_events_url": "https://api.github.com/users/CptMeetKat/received_events", "type": "User", "user_view_type": "public", "site_admin": false }, "labels": [], "state": "closed", "locked": false, "assignee": null, "assignees": [], "milestone": null, "comments": 9, "created_at": "2023-08-29T06:44:36Z", "updated_at": "2023-10-22T11:08:21Z", "closed_at": "2023-10-22T10:58:40Z", "author_association": "CONTRIBUTOR", "sub_issues_summary": { "total": 0, "completed": 0, "percent_completed": 0 }, "active_lock_reason": null, "draft": true, "pull_request": { "url": "https://api.github.com/repos/laurent22/joplin/pulls/8746", "html_url": "https://github.com/laurent22/joplin/pull/8746", "diff_url": "https://github.com/laurent22/joplin/pull/8746.diff", "patch_url": "https://github.com/laurent22/joplin/pull/8746.patch", "merged_at": null }, "body": "Previously when removing tags from the UI via the add/remove dialogue, the tags that were no longer associated with any notes (i.e. Orphaned) would remain in the database and accumulate needlessly.\r\n\r\nStep 1: Tag to be removed\r\n![image](https://github.com/laurent22/joplin/assets/32354598/821721af-9cfe-4fdf-a6cd-32159bc14235)\r\n\r\nStep 2: Once tag removed, tag persists in DB\r\n![image](https://github.com/laurent22/joplin/assets/32354598/2662a7e1-8c0a-433d-bd7a-72681c1bbab2)\r\n\r\nNow once a delete from note_tags table occurs (i.e. when NOTE_TAG_REMOVE has been signalled), a check to clear orphaned tags will be processed.\r\n\r\nFixes #8653", "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/8746/reactions", "total_count": 2, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 2, "rocket": 0, "eyes": 0 }, "timeline_url": "https://api.github.com/repos/laurent22/joplin/issues/8746/timeline", "performed_via_github_app": null, "state_reason": null }, "comments": [ { "url": "https://api.github.com/repos/laurent22/joplin/issues/comments/1696862382", "html_url": "https://github.com/laurent22/joplin/pull/8746#issuecomment-1696862382", "issue_url": "https://api.github.com/repos/laurent22/joplin/issues/8746", "id": 1696862382, "node_id": "IC_kwDOBLftOs5lJBCu", "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": "2023-08-29T06:44:54Z", "updated_at": "2023-10-22T11:08:21Z", "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/1696862382/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/1696922946", "html_url": "https://github.com/laurent22/joplin/pull/8746#issuecomment-1696922946", "issue_url": "https://api.github.com/repos/laurent22/joplin/issues/8746", "id": 1696922946, "node_id": "IC_kwDOBLftOs5lJP1C", "user": { "login": "CptMeetKat", "id": 32354598, "node_id": "MDQ6VXNlcjMyMzU0NTk4", "avatar_url": "https://avatars.githubusercontent.com/u/32354598?v=4", "gravatar_id": "", "url": "https://api.github.com/users/CptMeetKat", "html_url": "https://github.com/CptMeetKat", "followers_url": "https://api.github.com/users/CptMeetKat/followers", "following_url": "https://api.github.com/users/CptMeetKat/following{/other_user}", "gists_url": "https://api.github.com/users/CptMeetKat/gists{/gist_id}", "starred_url": "https://api.github.com/users/CptMeetKat/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/CptMeetKat/subscriptions", "organizations_url": "https://api.github.com/users/CptMeetKat/orgs", "repos_url": "https://api.github.com/users/CptMeetKat/repos", "events_url": "https://api.github.com/users/CptMeetKat/events{/privacy}", "received_events_url": "https://api.github.com/users/CptMeetKat/received_events", "type": "User", "user_view_type": "public", "site_admin": false }, "created_at": "2023-08-29T07:33:31Z", "updated_at": "2023-08-29T07:33:31Z", "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/1696922946/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/1697762369", "html_url": "https://github.com/laurent22/joplin/pull/8746#issuecomment-1697762369", "issue_url": "https://api.github.com/repos/laurent22/joplin/issues/8746", "id": 1697762369, "node_id": "IC_kwDOBLftOs5lMcxB", "user": { "login": "personalizedrefrigerator", "id": 46334387, "node_id": "MDQ6VXNlcjQ2MzM0Mzg3", "avatar_url": "https://avatars.githubusercontent.com/u/46334387?v=4", "gravatar_id": "", "url": "https://api.github.com/users/personalizedrefrigerator", "html_url": "https://github.com/personalizedrefrigerator", "followers_url": "https://api.github.com/users/personalizedrefrigerator/followers", "following_url": "https://api.github.com/users/personalizedrefrigerator/following{/other_user}", "gists_url": "https://api.github.com/users/personalizedrefrigerator/gists{/gist_id}", "starred_url": "https://api.github.com/users/personalizedrefrigerator/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/personalizedrefrigerator/subscriptions", "organizations_url": "https://api.github.com/users/personalizedrefrigerator/orgs", "repos_url": "https://api.github.com/users/personalizedrefrigerator/repos", "events_url": "https://api.github.com/users/personalizedrefrigerator/events{/privacy}", "received_events_url": "https://api.github.com/users/personalizedrefrigerator/received_events", "type": "User", "user_view_type": "public", "site_admin": false }, "created_at": "2023-08-29T16:16:22Z", "updated_at": "2023-08-29T16:17:06Z", "author_association": "COLLABORATOR", "body": "Thank you for contributing!\r\n\r\nFrom a quick look through the changes, \r\n1. Be sure to run the linter ­— see [`coding_style.md`](https://github.com/laurent22/joplin/blob/dev/readme/coding_style.md#enforcing-rules-using-eslint).\r\n2. Consider running `removeTagsWithoutNotes` when notes are deleted [(e.g. after a NOTE_DELETE action)](https://github.com/laurent22/joplin/blob/138f804580560ab61c05acb71f086d65ff3c46c7/packages/lib/components/shared/reduxSharedMiddleware.ts#L47) instead of when closing the tags dialog — this allows unused tags to be removed in the mobile/cli apps.", "reactions": { "url": "https://api.github.com/repos/laurent22/joplin/issues/comments/1697762369/reactions", "total_count": 1, "+1": 1, "-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/1706039794", "html_url": "https://github.com/laurent22/joplin/pull/8746#issuecomment-1706039794", "issue_url": "https://api.github.com/repos/laurent22/joplin/issues/8746", "id": 1706039794, "node_id": "IC_kwDOBLftOs5lsBny", "user": { "login": "CptMeetKat", "id": 32354598, "node_id": "MDQ6VXNlcjMyMzU0NTk4", "avatar_url": "https://avatars.githubusercontent.com/u/32354598?v=4", "gravatar_id": "", "url": "https://api.github.com/users/CptMeetKat", "html_url": "https://github.com/CptMeetKat", "followers_url": "https://api.github.com/users/CptMeetKat/followers", "following_url": "https://api.github.com/users/CptMeetKat/following{/other_user}", "gists_url": "https://api.github.com/users/CptMeetKat/gists{/gist_id}", "starred_url": "https://api.github.com/users/CptMeetKat/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/CptMeetKat/subscriptions", "organizations_url": "https://api.github.com/users/CptMeetKat/orgs", "repos_url": "https://api.github.com/users/CptMeetKat/repos", "events_url": "https://api.github.com/users/CptMeetKat/events{/privacy}", "received_events_url": "https://api.github.com/users/CptMeetKat/received_events", "type": "User", "user_view_type": "public", "site_admin": false }, "created_at": "2023-09-05T06:48:53Z", "updated_at": "2023-09-05T06:48:53Z", "author_association": "CONTRIBUTOR", "body": "@personalizedrefrigerator I've addressed the 2 issues, do you mind having another look for me?\r\n- linter was run\r\n- `removeTagsWithoutNotes` was moved to back end instead of on the dialogue", "reactions": { "url": "https://api.github.com/repos/laurent22/joplin/issues/comments/1706039794/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/1706052808", "html_url": "https://github.com/laurent22/joplin/pull/8746#issuecomment-1706052808", "issue_url": "https://api.github.com/repos/laurent22/joplin/issues/8746", "id": 1706052808, "node_id": "IC_kwDOBLftOs5lsEzI", "user": { "login": "personalizedrefrigerator", "id": 46334387, "node_id": "MDQ6VXNlcjQ2MzM0Mzg3", "avatar_url": "https://avatars.githubusercontent.com/u/46334387?v=4", "gravatar_id": "", "url": "https://api.github.com/users/personalizedrefrigerator", "html_url": "https://github.com/personalizedrefrigerator", "followers_url": "https://api.github.com/users/personalizedrefrigerator/followers", "following_url": "https://api.github.com/users/personalizedrefrigerator/following{/other_user}", "gists_url": "https://api.github.com/users/personalizedrefrigerator/gists{/gist_id}", "starred_url": "https://api.github.com/users/personalizedrefrigerator/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/personalizedrefrigerator/subscriptions", "organizations_url": "https://api.github.com/users/personalizedrefrigerator/orgs", "repos_url": "https://api.github.com/users/personalizedrefrigerator/repos", "events_url": "https://api.github.com/users/personalizedrefrigerator/events{/privacy}", "received_events_url": "https://api.github.com/users/personalizedrefrigerator/received_events", "type": "User", "user_view_type": "public", "site_admin": false }, "created_at": "2023-09-05T07:01:14Z", "updated_at": "2023-09-05T07:01:14Z", "author_association": "COLLABORATOR", "body": "From a quick look through the code, this looks good to me!\r\n\r\nThere are a few things I plan to check tomorrow:\r\n- Verify that tags only present in old revisions aren't deleted while the revisions still exist.\r\n - `tagsWithCount` may need to also search the revisions table ([example revisions-related query](https://github.com/laurent22/joplin/blob/7a8b69fa795a9e5a24ffeb84ab5ab86c375abcf1/packages/lib/models/Revision.ts#L255)).\r\n- This change doesn't cause a significant performance regression for thousands of notes/tags.", "reactions": { "url": "https://api.github.com/repos/laurent22/joplin/issues/comments/1706052808/reactions", "total_count": 1, "+1": 1, "-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/1706065794", "html_url": "https://github.com/laurent22/joplin/pull/8746#issuecomment-1706065794", "issue_url": "https://api.github.com/repos/laurent22/joplin/issues/8746", "id": 1706065794, "node_id": "IC_kwDOBLftOs5lsH-C", "user": { "login": "CptMeetKat", "id": 32354598, "node_id": "MDQ6VXNlcjMyMzU0NTk4", "avatar_url": "https://avatars.githubusercontent.com/u/32354598?v=4", "gravatar_id": "", "url": "https://api.github.com/users/CptMeetKat", "html_url": "https://github.com/CptMeetKat", "followers_url": "https://api.github.com/users/CptMeetKat/followers", "following_url": "https://api.github.com/users/CptMeetKat/following{/other_user}", "gists_url": "https://api.github.com/users/CptMeetKat/gists{/gist_id}", "starred_url": "https://api.github.com/users/CptMeetKat/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/CptMeetKat/subscriptions", "organizations_url": "https://api.github.com/users/CptMeetKat/orgs", "repos_url": "https://api.github.com/users/CptMeetKat/repos", "events_url": "https://api.github.com/users/CptMeetKat/events{/privacy}", "received_events_url": "https://api.github.com/users/CptMeetKat/received_events", "type": "User", "user_view_type": "public", "site_admin": false }, "created_at": "2023-09-05T07:12:50Z", "updated_at": "2023-09-05T07:12:50Z", "author_association": "CONTRIBUTOR", "body": "Thank you, I will also have a look in the meanwhile, appreciate any input in the matter.", "reactions": { "url": "https://api.github.com/repos/laurent22/joplin/issues/comments/1706065794/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/1711103301", "html_url": "https://github.com/laurent22/joplin/pull/8746#issuecomment-1711103301", "issue_url": "https://api.github.com/repos/laurent22/joplin/issues/8746", "id": 1711103301, "node_id": "IC_kwDOBLftOs5l_V1F", "user": { "login": "CptMeetKat", "id": 32354598, "node_id": "MDQ6VXNlcjMyMzU0NTk4", "avatar_url": "https://avatars.githubusercontent.com/u/32354598?v=4", "gravatar_id": "", "url": "https://api.github.com/users/CptMeetKat", "html_url": "https://github.com/CptMeetKat", "followers_url": "https://api.github.com/users/CptMeetKat/followers", "following_url": "https://api.github.com/users/CptMeetKat/following{/other_user}", "gists_url": "https://api.github.com/users/CptMeetKat/gists{/gist_id}", "starred_url": "https://api.github.com/users/CptMeetKat/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/CptMeetKat/subscriptions", "organizations_url": "https://api.github.com/users/CptMeetKat/orgs", "repos_url": "https://api.github.com/users/CptMeetKat/repos", "events_url": "https://api.github.com/users/CptMeetKat/events{/privacy}", "received_events_url": "https://api.github.com/users/CptMeetKat/received_events", "type": "User", "user_view_type": "public", "site_admin": false }, "created_at": "2023-09-08T05:36:00Z", "updated_at": "2023-09-08T05:36:00Z", "author_association": "CONTRIBUTOR", "body": "@personalizedrefrigerator I looked into your points\r\n\r\n1) Revisions don't use tags\r\n- Once a revision is restored without tags, it doesn't restore with any tags\r\n2) I modified the code to reduce joins in the database\r\n- `removeTagsWithoutNotes()` was replaced with `removeIfOrphan()`\r\n- This will only check if the current tag is an orphan when deleted, it will no longer check if unrelated tags are orphaned\r\n", "reactions": { "url": "https://api.github.com/repos/laurent22/joplin/issues/comments/1711103301/reactions", "total_count": 1, "+1": 1, "-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/1722425163", "html_url": "https://github.com/laurent22/joplin/pull/8746#issuecomment-1722425163", "issue_url": "https://api.github.com/repos/laurent22/joplin/issues/8746", "id": 1722425163, "node_id": "IC_kwDOBLftOs5mqh9L", "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": "2023-09-17T08:34:26Z", "updated_at": "2023-09-17T08:34:26Z", "author_association": "OWNER", "body": "Sync needs to be considered for this change because you delete a tag but it may still be in use on an unsynced device. For example in this case:\r\n\r\n- Device 1: Associate Tag 1 with note 1\r\n- Device 1: Sync\r\n- Device 2: Sync\r\n- Device 2: Remove Tag 1 from Note 1, and associated tag object gets deleted\r\n- Device 1: Associate Tag 1 with Note 2\r\n- Device 1: Sync\r\n\r\n=> Tag you've just associated with note 2 is gone", "reactions": { "url": "https://api.github.com/repos/laurent22/joplin/issues/comments/1722425163/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/1774062189", "html_url": "https://github.com/laurent22/joplin/pull/8746#issuecomment-1774062189", "issue_url": "https://api.github.com/repos/laurent22/joplin/issues/8746", "id": 1774062189, "node_id": "IC_kwDOBLftOs5pvgpt", "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": "2023-10-22T10:58:40Z", "updated_at": "2023-10-22T10:58:40Z", "author_association": "OWNER", "body": "Please see the comment above, I don't think we can merge this as it is", "reactions": { "url": "https://api.github.com/repos/laurent22/joplin/issues/comments/1774062189/reactions", "total_count": 1, "+1": 1, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 }, "performed_via_github_app": null } ] }