-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[AC-1597] Revert GetByUserIdWithPolicyDetailsAsync changes to unblock…
… SQL CPU (#3203) * Revert "[PM-3007] Caching user policies on PolicyService variable (#3117)" This reverts commit 78588d0. * Don't delete old migration script * Add migration to revert sproc (cherry picked from commit fc814ff)
- Loading branch information
Showing
8 changed files
with
71 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
...tor/DbScripts/2023-08-16_00_HotfixRevertOrganizationUserReadByUserIdWithPolicyDetails.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
CREATE OR ALTER PROCEDURE [dbo].[OrganizationUser_ReadByUserIdWithPolicyDetails] | ||
@UserId UNIQUEIDENTIFIER, | ||
@PolicyType TINYINT | ||
AS | ||
BEGIN | ||
SET NOCOUNT ON | ||
SELECT | ||
OU.[Id] AS OrganizationUserId, | ||
P.[OrganizationId], | ||
P.[Type] AS PolicyType, | ||
P.[Enabled] AS PolicyEnabled, | ||
P.[Data] AS PolicyData, | ||
OU.[Type] AS OrganizationUserType, | ||
OU.[Status] AS OrganizationUserStatus, | ||
OU.[Permissions] AS OrganizationUserPermissionsData, | ||
CASE WHEN EXISTS ( | ||
SELECT 1 | ||
FROM [dbo].[ProviderUserView] PU | ||
INNER JOIN [dbo].[ProviderOrganizationView] PO ON PO.[ProviderId] = PU.[ProviderId] | ||
WHERE PU.[UserId] = OU.[UserId] AND PO.[OrganizationId] = P.[OrganizationId] | ||
) THEN 1 ELSE 0 END AS IsProvider | ||
FROM [dbo].[PolicyView] P | ||
INNER JOIN [dbo].[OrganizationUserView] OU | ||
ON P.[OrganizationId] = OU.[OrganizationId] | ||
WHERE P.[Type] = @PolicyType AND | ||
( | ||
(OU.[Status] != 0 AND OU.[UserId] = @UserId) -- OrgUsers who have accepted their invite and are linked to a UserId | ||
OR EXISTS ( | ||
SELECT 1 | ||
FROM [dbo].[UserView] U | ||
WHERE U.[Id] = @UserId AND OU.[Email] = U.[Email] AND OU.[Status] = 0 -- 'Invited' OrgUsers are not linked to a UserId yet, so we have to look up their email | ||
) | ||
) | ||
END | ||
GO |