Skip to content

Commit

Permalink
Cy's feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
amorask-bitwarden committed Oct 6, 2023
1 parent 83f95fd commit 7bebd6e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -232,12 +232,15 @@ public async Task<IEnumerable<string>> GetOwnerEmailAddressesById(Guid organizat
var dbContext = GetDatabaseContext(scope);

var query =
from o in dbContext.Organizations
join ou in dbContext.OrganizationUsers on o.Id equals ou.OrganizationId
join u in dbContext.Users on ou.UserId equals u.Id
where ou.Type == OrganizationUserType.Owner &&
ou.Status == OrganizationUserStatusType.Confirmed
select u.Email;
from u in dbContext.Users
join ou in dbContext.OrganizationUsers on u.Id equals ou.UserId
where
ou.OrganizationId == organizationId &&
ou.Type == OrganizationUserType.Owner &&
ou.Status == OrganizationUserStatusType.Confirmed
group u by u.Email
into grouped
select grouped.Key;

return await query.ToListAsync();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ CREATE OR ALTER PROCEDURE [dbo].[Organization_ReadOwnerEmailAddressesById]
AS
BEGIN
SET NOCOUNT ON

SELECT
U.[Email]
FROM
Organization AS O
INNER JOIN OrganizationUser AS OU ON O.[Id] = OU.[OrganizationId]
INNER JOIN [User] AS U ON OU.[UserId] = U.[Id]
[U].[Email]
FROM [User] AS [U]
INNER JOIN [OrganizationUser] AS [OU] ON [U].[Id] = [OU].[UserId]
WHERE
O.[Id] = @OrganizationId AND
OU.[Type] = 0 AND -- Owner
OU.[Status] = 2 -- Confirmed
[OU].[OrganizationId] = @OrganizationId AND
[OU].[Type] = 0 AND -- Owner
[OU].[Status] = 2 -- Confirmed
GROUP BY [U].[Email]
END
GO

0 comments on commit 7bebd6e

Please sign in to comment.