From d7cb3d47cb0e0256c81593d1b97db6ed535e31db Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Fri, 6 May 2016 18:23:43 -0400 Subject: [PATCH] removed GetManyByRevisionDate access --- src/Api/Controllers/FoldersController.cs | 16 ++++------------ src/Api/Controllers/SitesController.cs | 13 ++----------- src/Core/Repositories/IFolderRepository.cs | 1 - src/Core/Repositories/ISiteRepository.cs | 1 - .../Repositories/SqlServer/FolderRepository.cs | 13 ------------- .../Repositories/SqlServer/SiteRepository.cs | 13 ------------- src/Sql/Sql.sqlproj | 2 -- .../Folder_ReadByRevisionDate.sql | 13 ------------- .../Site_ReadByRevisionDate.sql | 13 ------------- 9 files changed, 6 insertions(+), 79 deletions(-) delete mode 100644 src/Sql/dbo/Stored Procedures/Folder_ReadByRevisionDate.sql delete mode 100644 src/Sql/dbo/Stored Procedures/Site_ReadByRevisionDate.sql diff --git a/src/Api/Controllers/FoldersController.cs b/src/Api/Controllers/FoldersController.cs index a0183e43b..912003df6 100644 --- a/src/Api/Controllers/FoldersController.cs +++ b/src/Api/Controllers/FoldersController.cs @@ -37,19 +37,11 @@ namespace Bit.Api.Controllers } [HttpGet("")] - public async Task> Get(DateTime? since = null) + public async Task> Get() { - ICollection folders = null; - if(since.HasValue) - { - folders = await _folderRepository.GetManyByRevisionDateAsync(User.GetUserId(), since.Value); - } - else - { - folders = await _folderRepository.GetManyByUserIdAsync(User.GetUserId()); - } - - return new ListResponseModel(folders.Select(f => new FolderResponseModel(f))); + ICollection folders = await _folderRepository.GetManyByUserIdAsync(User.GetUserId()); + var responses = folders.Select(f => new FolderResponseModel(f)); + return new ListResponseModel(responses); } [HttpPost("")] diff --git a/src/Api/Controllers/SitesController.cs b/src/Api/Controllers/SitesController.cs index acab6434f..11b2ba75f 100644 --- a/src/Api/Controllers/SitesController.cs +++ b/src/Api/Controllers/SitesController.cs @@ -42,18 +42,9 @@ namespace Bit.Api.Controllers } [HttpGet("")] - public async Task> Get(DateTime? since = null, string[] expand = null) + public async Task> Get(string[] expand = null) { - ICollection sites = null; - if(since.HasValue) - { - sites = await _siteRepository.GetManyByRevisionDateAsync(User.GetUserId(), since.Value); - } - else - { - sites = await _siteRepository.GetManyByUserIdAsync(User.GetUserId()); - } - + ICollection sites = await _siteRepository.GetManyByUserIdAsync(User.GetUserId()); var responses = sites.Select(s => new SiteResponseModel(s)).ToList(); await ExpandManyAsync(sites, responses, expand, null); return new ListResponseModel(responses); diff --git a/src/Core/Repositories/IFolderRepository.cs b/src/Core/Repositories/IFolderRepository.cs index 48d524046..3d4ce6ade 100644 --- a/src/Core/Repositories/IFolderRepository.cs +++ b/src/Core/Repositories/IFolderRepository.cs @@ -9,6 +9,5 @@ namespace Bit.Core.Repositories { Task GetByIdAsync(string id, string userId); Task> GetManyByUserIdAsync(string userId); - Task> GetManyByRevisionDateAsync(string userId, DateTime sinceRevisionDate); } } diff --git a/src/Core/Repositories/ISiteRepository.cs b/src/Core/Repositories/ISiteRepository.cs index 7d081ba83..f9aeeba8a 100644 --- a/src/Core/Repositories/ISiteRepository.cs +++ b/src/Core/Repositories/ISiteRepository.cs @@ -9,6 +9,5 @@ namespace Bit.Core.Repositories { Task GetByIdAsync(string id, string userId); Task> GetManyByUserIdAsync(string userId); - Task> GetManyByRevisionDateAsync(string userId, DateTime sinceRevisionDate); } } diff --git a/src/Core/Repositories/SqlServer/FolderRepository.cs b/src/Core/Repositories/SqlServer/FolderRepository.cs index e26495a6f..fb1b9b908 100644 --- a/src/Core/Repositories/SqlServer/FolderRepository.cs +++ b/src/Core/Repositories/SqlServer/FolderRepository.cs @@ -39,18 +39,5 @@ namespace Bit.Core.Repositories.SqlServer return results.Select(f => f.ToDomain()).ToList(); } } - - public async Task> GetManyByRevisionDateAsync(string userId, DateTime sinceRevisionDate) - { - using(var connection = new SqlConnection(ConnectionString)) - { - var results = await connection.QueryAsync( - $"[{Schema}].[{Table}_ReadByRevisionDate]", - new { UserId = new Guid(userId), SinceRevisionDate = sinceRevisionDate }, - commandType: CommandType.StoredProcedure); - - return results.Select(f => f.ToDomain()).ToList(); - } - } } } diff --git a/src/Core/Repositories/SqlServer/SiteRepository.cs b/src/Core/Repositories/SqlServer/SiteRepository.cs index dc0b0e266..8ec07ba45 100644 --- a/src/Core/Repositories/SqlServer/SiteRepository.cs +++ b/src/Core/Repositories/SqlServer/SiteRepository.cs @@ -39,18 +39,5 @@ namespace Bit.Core.Repositories.SqlServer return results.Select(s => s.ToDomain()).ToList(); } } - - public async Task> GetManyByRevisionDateAsync(string userId, DateTime sinceRevisionDate) - { - using(var connection = new SqlConnection(ConnectionString)) - { - var results = await connection.QueryAsync( - $"[{Schema}].[{Table}_ReadByRevisionDate]", - new { UserId = new Guid(userId), SinceRevisionDate = sinceRevisionDate }, - commandType: CommandType.StoredProcedure); - - return results.Select(f => f.ToDomain()).ToList(); - } - } } } diff --git a/src/Sql/Sql.sqlproj b/src/Sql/Sql.sqlproj index 7e87ee146..009c63fee 100644 --- a/src/Sql/Sql.sqlproj +++ b/src/Sql/Sql.sqlproj @@ -88,7 +88,5 @@ - - \ No newline at end of file diff --git a/src/Sql/dbo/Stored Procedures/Folder_ReadByRevisionDate.sql b/src/Sql/dbo/Stored Procedures/Folder_ReadByRevisionDate.sql deleted file mode 100644 index 724561ccf..000000000 --- a/src/Sql/dbo/Stored Procedures/Folder_ReadByRevisionDate.sql +++ /dev/null @@ -1,13 +0,0 @@ -CREATE PROCEDURE [dbo].[Folder_ReadByRevisionDate] - @UserId UNIQUEIDENTIFIER, - @SinceRevisionDate DATETIME -AS -BEGIN - SELECT - * - FROM - [dbo].[FolderView] - WHERE - [UserId] = @UserId - AND [RevisionDate] >= @SinceRevisionDate -END diff --git a/src/Sql/dbo/Stored Procedures/Site_ReadByRevisionDate.sql b/src/Sql/dbo/Stored Procedures/Site_ReadByRevisionDate.sql deleted file mode 100644 index fe6bf12c9..000000000 --- a/src/Sql/dbo/Stored Procedures/Site_ReadByRevisionDate.sql +++ /dev/null @@ -1,13 +0,0 @@ -CREATE PROCEDURE [dbo].[Site_ReadByRevisionDate] - @UserId UNIQUEIDENTIFIER, - @SinceRevisionDate DATETIME -AS -BEGIN - SELECT - * - FROM - [dbo].[SiteView] - WHERE - [UserId] = @UserId - AND [RevisionDate] >= @SinceRevisionDate -END