Use the year, month, day properties of ExecutionTime instead of Date.

pull/2307/head
maliming 6 years ago
parent dc33dd3b2e
commit 31d50f07b7

@ -124,13 +124,17 @@ namespace Volo.Abp.AuditLogging.MongoDB
public async Task<Dictionary<DateTime, double>> GetAverageExecutionDurationPerDayAsync(DateTime startDate, DateTime endDate)
{
var result = (await GetMongoQueryable()
var result = await GetMongoQueryable()
.Where(a => a.ExecutionTime < endDate.AddDays(1) && a.ExecutionTime > startDate)
.OrderBy(t => t.ExecutionTime)
.ToListAsync())
.GroupBy(t => new { t.ExecutionTime.Date })
.GroupBy(t => new
{
t.ExecutionTime.Year,
t.ExecutionTime.Month,
t.ExecutionTime.Day
})
.Select(g => new { Day = g.Min(t => t.ExecutionTime), avgExecutionTime = g.Average(t => t.ExecutionDuration) })
.ToList();
.ToListAsync();
return result.ToDictionary(element => element.Day.ClearTime(), element => element.avgExecutionTime);
}

Loading…
Cancel
Save