mirror of
https://github.com/bitwarden/server.git
synced 2025-07-06 18:42:49 -05:00
sql event repo "Get" implementations
This commit is contained in:
@ -219,5 +219,9 @@
|
||||
<Build Include="dbo\Tables\Event.sql" />
|
||||
<Build Include="dbo\Stored Procedures\Event_Create.sql" />
|
||||
<Build Include="dbo\Views\EventView.sql" />
|
||||
<Build Include="dbo\Stored Procedures\Event_ReadPageByUserId.sql" />
|
||||
<Build Include="dbo\Stored Procedures\Event_ReadPageByOrganizationId.sql" />
|
||||
<Build Include="dbo\Stored Procedures\Event_ReadPageByCipherId.sql" />
|
||||
<Build Include="dbo\Stored Procedures\Event_ReadPageByOrganizationIdActingUserId.sql" />
|
||||
</ItemGroup>
|
||||
</Project>
|
33
src/Sql/dbo/Stored Procedures/Event_ReadPageByCipherId.sql
Normal file
33
src/Sql/dbo/Stored Procedures/Event_ReadPageByCipherId.sql
Normal file
@ -0,0 +1,33 @@
|
||||
CREATE PROCEDURE [dbo].[Event_ReadPageByCipherId]
|
||||
@OrganizationId UNIQUEIDENTIFIER,
|
||||
@UserId UNIQUEIDENTIFIER,
|
||||
@CipherId UNIQUEIDENTIFIER,
|
||||
@StartDate DATETIME2(7),
|
||||
@EndDate DATETIME2(7),
|
||||
@BeforeDate DATETIME2(7),
|
||||
@PageSize INT
|
||||
AS
|
||||
BEGIN
|
||||
SET NOCOUNT ON
|
||||
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
[dbo].[EventView]
|
||||
WHERE
|
||||
[Date] >= @StartDate
|
||||
AND (@BeforeDate IS NOT NULL OR [Date] <= @EndDate)
|
||||
AND (@BeforeDate IS NULL OR [Date] < @BeforeDate)
|
||||
AND (
|
||||
(@OrganizationId IS NULL AND [OrganizationId] IS NULL)
|
||||
OR (@OrganizationId IS NOT NULL AND [OrganizationId] = @OrganizationId)
|
||||
)
|
||||
AND (
|
||||
(@UserId IS NULL AND [UserId] IS NULL)
|
||||
OR (@UserId IS NOT NULL AND [UserId] = @UserId)
|
||||
)
|
||||
AND [CipherId] = @CipherId
|
||||
ORDER BY [Date] DESC
|
||||
OFFSET 0 ROWS
|
||||
FETCH NEXT @PageSize ROWS ONLY
|
||||
END
|
@ -0,0 +1,23 @@
|
||||
CREATE PROCEDURE [dbo].[Event_ReadPageByOrganizationId]
|
||||
@OrganizationId UNIQUEIDENTIFIER,
|
||||
@StartDate DATETIME2(7),
|
||||
@EndDate DATETIME2(7),
|
||||
@BeforeDate DATETIME2(7),
|
||||
@PageSize INT
|
||||
AS
|
||||
BEGIN
|
||||
SET NOCOUNT ON
|
||||
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
[dbo].[EventView]
|
||||
WHERE
|
||||
[Date] >= @StartDate
|
||||
AND (@BeforeDate IS NOT NULL OR [Date] <= @EndDate)
|
||||
AND (@BeforeDate IS NULL OR [Date] < @BeforeDate)
|
||||
AND [OrganizationId] = @OrganizationId
|
||||
ORDER BY [Date] DESC
|
||||
OFFSET 0 ROWS
|
||||
FETCH NEXT @PageSize ROWS ONLY
|
||||
END
|
@ -0,0 +1,25 @@
|
||||
CREATE PROCEDURE [dbo].[Event_ReadPageByOrganizationIdActingUserId]
|
||||
@OrganizationId UNIQUEIDENTIFIER,
|
||||
@ActingUserId UNIQUEIDENTIFIER,
|
||||
@StartDate DATETIME2(7),
|
||||
@EndDate DATETIME2(7),
|
||||
@BeforeDate DATETIME2(7),
|
||||
@PageSize INT
|
||||
AS
|
||||
BEGIN
|
||||
SET NOCOUNT ON
|
||||
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
[dbo].[EventView]
|
||||
WHERE
|
||||
[Date] >= @StartDate
|
||||
AND (@BeforeDate IS NOT NULL OR [Date] <= @EndDate)
|
||||
AND (@BeforeDate IS NULL OR [Date] < @BeforeDate)
|
||||
AND [OrganizationId] = @OrganizationId
|
||||
AND [ActingUserId] = @ActingUserId
|
||||
ORDER BY [Date] DESC
|
||||
OFFSET 0 ROWS
|
||||
FETCH NEXT @PageSize ROWS ONLY
|
||||
END
|
24
src/Sql/dbo/Stored Procedures/Event_ReadPageByUserId.sql
Normal file
24
src/Sql/dbo/Stored Procedures/Event_ReadPageByUserId.sql
Normal file
@ -0,0 +1,24 @@
|
||||
CREATE PROCEDURE [dbo].[Event_ReadPageByUserId]
|
||||
@UserId UNIQUEIDENTIFIER,
|
||||
@StartDate DATETIME2(7),
|
||||
@EndDate DATETIME2(7),
|
||||
@BeforeDate DATETIME2(7),
|
||||
@PageSize INT
|
||||
AS
|
||||
BEGIN
|
||||
SET NOCOUNT ON
|
||||
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
[dbo].[EventView]
|
||||
WHERE
|
||||
[Date] >= @StartDate
|
||||
AND (@BeforeDate IS NOT NULL OR [Date] <= @EndDate)
|
||||
AND (@BeforeDate IS NULL OR [Date] < @BeforeDate)
|
||||
AND [OrganizationId] IS NULL
|
||||
AND [ActingUserId] = @UserId
|
||||
ORDER BY [Date] DESC
|
||||
OFFSET 0 ROWS
|
||||
FETCH NEXT @PageSize ROWS ONLY
|
||||
END
|
@ -17,5 +17,5 @@
|
||||
|
||||
GO
|
||||
CREATE NONCLUSTERED INDEX [IX_Event_DateOrganizationIdUserId]
|
||||
ON [dbo].[Event]([Date] ASC, [OrganizationId] ASC, [UserId] ASC, [CipherId] ASC);
|
||||
ON [dbo].[Event]([Date] DESC, [OrganizationId] ASC, [ActingUserId] ASC, [CipherId] ASC);
|
||||
|
||||
|
Reference in New Issue
Block a user