main ← fix-bookmark-count
opened 10:52AM - 24 Dec 25 UTC
Previously, `UserSummary#bookmark_count` used a simple `Bookmark.where(user:).co…unt` which included bookmarks for content the user could no longer access (e.g., topics moved to private categories, deleted posts, or PMs they were removed from). This caused a mismatch where users saw "4 bookmarks" in their profile stats but an empty bookmark page.
Added `BookmarkQuery#count_all` that reuses the same access-filtered UNION query as `list_all`, ensuring the count reflects only accessible bookmarks.
Also refactored `BookmarkQuery` for clarity:
- Extracted `build_list_queries` to share query building between `count_all` and `list_all`
- Extracted helper methods in `unread_notifications`: `fetch_reminder_notifications`, `load_deleted_bookmarkables`, `can_see_notification_bookmark?`
- Removed verbose comments and debug SQL formatting
Ref - https://meta.discourse.org/t/391822