1
0
mirror of https://github.com/bitwarden/server.git synced 2024-11-25 12:45:18 +01:00

Added get for sso config repo by revision date (#878)

This commit is contained in:
Chad Scharf 2020-08-19 13:35:17 -04:00 committed by GitHub
parent 80f57d22a7
commit 8884157427
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 51 additions and 0 deletions

View File

@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Bit.Core.Models.Table;
@ -8,5 +9,6 @@ namespace Bit.Core.Repositories
{
Task<SsoConfig> GetByOrganizationIdAsync(Guid organizationId);
Task<SsoConfig> GetByIdentifierAsync(string identifier);
Task<ICollection<SsoConfig>> GetManyByRevisionNotBeforeDate(DateTime? notBefore);
}
}

View File

@ -5,6 +5,7 @@ using System.Data.SqlClient;
using System.Data;
using Dapper;
using System.Linq;
using System.Collections.Generic;
namespace Bit.Core.Repositories.SqlServer
{
@ -43,5 +44,18 @@ namespace Bit.Core.Repositories.SqlServer
return results.SingleOrDefault();
}
}
public async Task<ICollection<SsoConfig>> GetManyByRevisionNotBeforeDate(DateTime? notBefore)
{
using (var connection = new SqlConnection(ConnectionString))
{
var results = await connection.QueryAsync<SsoConfig>(
$"[{Schema}].[{Table}_ReadManyByNotBeforeRevisionDate]",
new { NotBefore = notBefore },
commandType: CommandType.StoredProcedure);
return results.ToList();
}
}
}
}

View File

@ -0,0 +1,14 @@
CREATE PROCEDURE [dbo].[SsoConfig_ReadManyByNotBeforeRevisionDate]
@NotBefore DATETIME2(7)
AS
BEGIN
SET NOCOUNT ON
SELECT
*
FROM
[dbo].[SsoConfigView]
WHERE
[Enabled] = 1
AND [RevisionDate] >= COALESCE(@NotBefore, [RevisionDate]);
END

View File

@ -0,0 +1,21 @@
IF OBJECT_ID('[dbo].[SsoConfig_ReadManyByNotBeforeRevisionDate]') IS NOT NULL
BEGIN
DROP PROCEDURE [dbo].[SsoConfig_ReadManyByNotBeforeRevisionDate]
END
GO
CREATE PROCEDURE [dbo].[SsoConfig_ReadManyByNotBeforeRevisionDate]
@NotBefore DATETIME2(7)
AS
BEGIN
SET NOCOUNT ON
SELECT
*
FROM
[dbo].[SsoConfigView]
WHERE
[Enabled] = 1
AND [RevisionDate] >= COALESCE(@NotBefore, [RevisionDate]);
END
GO