1
0
mirror of https://github.com/bitwarden/server synced 2025-12-26 21:23:39 +00:00

date range search on logs

This commit is contained in:
Kyle Spearrin
2019-10-01 09:02:36 -04:00
parent b99f6cdbc1
commit 47fed7ab80
3 changed files with 17 additions and 2 deletions

View File

@@ -27,7 +27,7 @@ namespace Bit.Admin.Controllers
}
public async Task<IActionResult> Index(string cursor = null, int count = 50,
LogEventLevel? level = null, string project = null)
LogEventLevel? level = null, string project = null, DateTime? start = null, DateTime? end = null)
{
var collectionLink = UriFactory.CreateDocumentCollectionUri(Database, Collection);
using(var client = new DocumentClient(new Uri(_globalSettings.DocumentDb.Uri),
@@ -48,6 +48,14 @@ namespace Bit.Admin.Controllers
{
query = query.Where(l => l.Properties != null && l.Properties["Project"] == (object)project);
}
if(start.HasValue)
{
query = query.Where(l => l.Timestamp >= start.Value);
}
if(end.HasValue)
{
query = query.Where(l => l.Timestamp <= end.Value);
}
var docQuery = query.OrderByDescending(l => l.Timestamp).AsDocumentQuery();
var response = await docQuery.ExecuteNextAsync<LogModel>();
@@ -56,6 +64,8 @@ namespace Bit.Admin.Controllers
{
Level = level,
Project = project,
Start = start,
End = end,
Items = response.ToList(),
Count = count,
Cursor = cursor,