Browse Source

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

pull/2307/head
maliming 7 years ago
parent
commit
31d50f07b7
  1. 12
      modules/audit-logging/src/Volo.Abp.AuditLogging.MongoDB/Volo/Abp/AuditLogging/MongoDB/MongoAuditLogRepository.cs

12
modules/audit-logging/src/Volo.Abp.AuditLogging.MongoDB/Volo/Abp/AuditLogging/MongoDB/MongoAuditLogRepository.cs

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