core: only include mentions in unread count for groups with mentions-only notifications (#5601)

* core: only include mentions in unread count for groups with mentions-only notifications

* remove whitespace

* update nft servers

* update query plans
This commit is contained in:
Evgeny
2025-02-02 23:30:52 +00:00
committed by GitHub
parent 442282be93
commit 43e374cf20
4 changed files with 10 additions and 8 deletions
+3 -3
View File
@@ -643,11 +643,11 @@ deleteGroupChatItems db User {userId} GroupInfo {groupId} =
deleteGroupMembers :: DB.Connection -> User -> GroupInfo -> IO ()
deleteGroupMembers db User {userId} GroupInfo {groupId} = do
DB.execute_ db "DROP TABLE IF EXISTS temp_delete_members"
#if defined(dbPostgres)
#if defined(dbPostgres)
DB.execute_ db "CREATE TABLE temp_delete_members (contact_profile_id BIGINT, member_profile_id BIGINT, local_display_name TEXT)"
#else
#else
DB.execute_ db "CREATE TABLE temp_delete_members (contact_profile_id INTEGER, member_profile_id INTEGER, local_display_name TEXT)"
#endif
#endif
DB.execute
db
[sql|
+2 -1
View File
@@ -174,7 +174,8 @@ getUsersInfo db = getUsers db >>= mapM getUserInfo
SELECT COUNT(1)
FROM chat_items i
JOIN groups g USING (group_id)
WHERE i.user_id = ? AND i.item_status = ? AND (g.enable_ntfs = 1 OR g.enable_ntfs IS NULL)
WHERE i.user_id = ? AND i.item_status = ?
AND (g.enable_ntfs = 1 OR g.enable_ntfs IS NULL OR (g.enable_ntfs = 2 AND i.user_mention = 1))
|]
(userId, CISRcvNew)
pure UserInfo {user, unreadCount = fromMaybe 0 ctCount + fromMaybe 0 gCount}
@@ -154,7 +154,8 @@ Query:
SELECT COUNT(1)
FROM chat_items i
JOIN groups g USING (group_id)
WHERE i.user_id = ? AND i.item_status = ? AND (g.enable_ntfs = 1 OR g.enable_ntfs IS NULL)
WHERE i.user_id = ? AND i.item_status = ?
AND (g.enable_ntfs = 1 OR g.enable_ntfs IS NULL OR (g.enable_ntfs = 2 AND i.user_mention = 1))
Plan:
SEARCH i USING COVERING INDEX idx_chat_items_groups_user_mention (user_id=?)