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

removed GetManyByRevisionDate access

This commit is contained in:
Kyle Spearrin 2016-05-06 18:23:43 -04:00
parent 0d92042e28
commit d7cb3d47cb
9 changed files with 6 additions and 79 deletions

View File

@ -37,19 +37,11 @@ namespace Bit.Api.Controllers
} }
[HttpGet("")] [HttpGet("")]
public async Task<ListResponseModel<FolderResponseModel>> Get(DateTime? since = null) public async Task<ListResponseModel<FolderResponseModel>> Get()
{ {
ICollection<Folder> folders = null; ICollection<Folder> folders = await _folderRepository.GetManyByUserIdAsync(User.GetUserId());
if(since.HasValue) var responses = folders.Select(f => new FolderResponseModel(f));
{ return new ListResponseModel<FolderResponseModel>(responses);
folders = await _folderRepository.GetManyByRevisionDateAsync(User.GetUserId(), since.Value);
}
else
{
folders = await _folderRepository.GetManyByUserIdAsync(User.GetUserId());
}
return new ListResponseModel<FolderResponseModel>(folders.Select(f => new FolderResponseModel(f)));
} }
[HttpPost("")] [HttpPost("")]

View File

@ -42,18 +42,9 @@ namespace Bit.Api.Controllers
} }
[HttpGet("")] [HttpGet("")]
public async Task<ListResponseModel<SiteResponseModel>> Get(DateTime? since = null, string[] expand = null) public async Task<ListResponseModel<SiteResponseModel>> Get(string[] expand = null)
{ {
ICollection<Site> sites = null; ICollection<Site> sites = await _siteRepository.GetManyByUserIdAsync(User.GetUserId());
if(since.HasValue)
{
sites = await _siteRepository.GetManyByRevisionDateAsync(User.GetUserId(), since.Value);
}
else
{
sites = await _siteRepository.GetManyByUserIdAsync(User.GetUserId());
}
var responses = sites.Select(s => new SiteResponseModel(s)).ToList(); var responses = sites.Select(s => new SiteResponseModel(s)).ToList();
await ExpandManyAsync(sites, responses, expand, null); await ExpandManyAsync(sites, responses, expand, null);
return new ListResponseModel<SiteResponseModel>(responses); return new ListResponseModel<SiteResponseModel>(responses);

View File

@ -9,6 +9,5 @@ namespace Bit.Core.Repositories
{ {
Task<Folder> GetByIdAsync(string id, string userId); Task<Folder> GetByIdAsync(string id, string userId);
Task<ICollection<Folder>> GetManyByUserIdAsync(string userId); Task<ICollection<Folder>> GetManyByUserIdAsync(string userId);
Task<ICollection<Folder>> GetManyByRevisionDateAsync(string userId, DateTime sinceRevisionDate);
} }
} }

View File

@ -9,6 +9,5 @@ namespace Bit.Core.Repositories
{ {
Task<Site> GetByIdAsync(string id, string userId); Task<Site> GetByIdAsync(string id, string userId);
Task<ICollection<Site>> GetManyByUserIdAsync(string userId); Task<ICollection<Site>> GetManyByUserIdAsync(string userId);
Task<ICollection<Site>> GetManyByRevisionDateAsync(string userId, DateTime sinceRevisionDate);
} }
} }

View File

@ -39,18 +39,5 @@ namespace Bit.Core.Repositories.SqlServer
return results.Select(f => f.ToDomain()).ToList(); return results.Select(f => f.ToDomain()).ToList();
} }
} }
public async Task<ICollection<Folder>> GetManyByRevisionDateAsync(string userId, DateTime sinceRevisionDate)
{
using(var connection = new SqlConnection(ConnectionString))
{
var results = await connection.QueryAsync<FolderTableModel>(
$"[{Schema}].[{Table}_ReadByRevisionDate]",
new { UserId = new Guid(userId), SinceRevisionDate = sinceRevisionDate },
commandType: CommandType.StoredProcedure);
return results.Select(f => f.ToDomain()).ToList();
}
}
} }
} }

View File

@ -39,18 +39,5 @@ namespace Bit.Core.Repositories.SqlServer
return results.Select(s => s.ToDomain()).ToList(); return results.Select(s => s.ToDomain()).ToList();
} }
} }
public async Task<ICollection<Site>> GetManyByRevisionDateAsync(string userId, DateTime sinceRevisionDate)
{
using(var connection = new SqlConnection(ConnectionString))
{
var results = await connection.QueryAsync<SiteTableModel>(
$"[{Schema}].[{Table}_ReadByRevisionDate]",
new { UserId = new Guid(userId), SinceRevisionDate = sinceRevisionDate },
commandType: CommandType.StoredProcedure);
return results.Select(f => f.ToDomain()).ToList();
}
}
} }
} }

View File

@ -88,7 +88,5 @@
<Build Include="dbo\Stored Procedures\Folder_Update.sql" /> <Build Include="dbo\Stored Procedures\Folder_Update.sql" />
<Build Include="dbo\Stored Procedures\Cipher_ReadByUserId.sql" /> <Build Include="dbo\Stored Procedures\Cipher_ReadByUserId.sql" />
<Build Include="dbo\Stored Procedures\User_UpdateEmailPassword.sql" /> <Build Include="dbo\Stored Procedures\User_UpdateEmailPassword.sql" />
<Build Include="dbo\Stored Procedures\Folder_ReadByRevisionDate.sql" />
<Build Include="dbo\Stored Procedures\Site_ReadByRevisionDate.sql" />
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@ -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

View File

@ -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