Skip to content

Commit

Permalink
PM-10560: Notification ReadByUserIdAndStatus fix
Browse files Browse the repository at this point in the history
  • Loading branch information
mzieniukbw committed Sep 9, 2024
1 parent acef48b commit ddbacac
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ BEGIN
FROM [dbo].[NotificationView] n
LEFT JOIN [dbo].[OrganizationUserView] ou ON n.[OrganizationId] = ou.[OrganizationId]
AND ou.[UserId] = @UserId
JOIN [dbo].[NotificationStatusView] ns ON n.[Id] = ns.[NotificationId]
LEFT JOIN [dbo].[NotificationStatusView] ns ON n.[Id] = ns.[NotificationId]
AND ns.[UserId] = @UserId
WHERE [ClientType] IN (0, CASE WHEN @ClientType != 0 THEN @ClientType END)
AND ([Global] = 1
Expand All @@ -20,13 +20,13 @@ BEGIN
OR ou.[OrganizationId] IS NOT NULL))
OR (n.[UserId] IS NULL
AND ou.[OrganizationId] IS NOT NULL))
AND (@Read IS NULL
AND ((@Read IS NULL
OR IIF((@Read = 1 AND ns.[ReadDate] IS NOT NULL) OR
(@Read = 0 AND ns.[ReadDate] IS NULL),
1, 0) = 1
OR @Deleted IS NULL
OR IIF((@Deleted = 1 AND ns.[DeletedDate] IS NOT NULL) OR
(@Deleted = 0 AND ns.[DeletedDate] IS NULL),
1, 0) = 1)
OR (@Deleted IS NULL
OR IIF((@Deleted = 1 AND ns.[DeletedDate] IS NOT NULL) OR
(@Deleted = 0 AND ns.[DeletedDate] IS NULL),
1, 0) = 1))
ORDER BY [Priority] DESC, n.[CreationDate] DESC
END
12 changes: 6 additions & 6 deletions util/Migrator/DbScripts/2024-09-06_00_NotificationCenter.sql
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ BEGIN
FROM [dbo].[NotificationView] n
LEFT JOIN [dbo].[OrganizationUserView] ou ON n.[OrganizationId] = ou.[OrganizationId]
AND ou.[UserId] = @UserId
JOIN [dbo].[NotificationStatusView] ns ON n.[Id] = ns.[NotificationId]
LEFT JOIN [dbo].[NotificationStatusView] ns ON n.[Id] = ns.[NotificationId]
AND ns.[UserId] = @UserId
WHERE [ClientType] IN (0, CASE WHEN @ClientType != 0 THEN @ClientType END)
AND ([Global] = 1
Expand All @@ -173,14 +173,14 @@ BEGIN
OR ou.[OrganizationId] IS NOT NULL))
OR (n.[UserId] IS NULL
AND ou.[OrganizationId] IS NOT NULL))
AND (@Read IS NULL
AND ((@Read IS NULL
OR IIF((@Read = 1 AND ns.[ReadDate] IS NOT NULL) OR
(@Read = 0 AND ns.[ReadDate] IS NULL),
1, 0) = 1
OR @Deleted IS NULL
OR IIF((@Deleted = 1 AND ns.[DeletedDate] IS NOT NULL) OR
(@Deleted = 0 AND ns.[DeletedDate] IS NULL),
1, 0) = 1)
OR (@Deleted IS NULL
OR IIF((@Deleted = 1 AND ns.[DeletedDate] IS NOT NULL) OR
(@Deleted = 0 AND ns.[DeletedDate] IS NULL),
1, 0) = 1))
ORDER BY [Priority] DESC, n.[CreationDate] DESC
END
GO
Expand Down

0 comments on commit ddbacac

Please sign in to comment.