Browse Source
Merge pull request #1859 from abpframework/GetAverageExecutionDurationPerDayAsync-Method-In-AuditLogging
added GetAverageExecutionDurationPerDayAsync
pull/1879/head
Halil İbrahim Kalkan
7 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with
29 additions and
0 deletions
-
modules/audit-logging/src/Volo.Abp.AuditLogging.Domain/Volo/Abp/AuditLogging/IAuditLogRepository.cs
-
modules/audit-logging/src/Volo.Abp.AuditLogging.EntityFrameworkCore/Volo/Abp/AuditLogging/EntityFrameworkCore/EfCoreAuditLogRepository.cs
-
modules/audit-logging/src/Volo.Abp.AuditLogging.MongoDB/Volo/Abp/AuditLogging/MongoDB/MongoAuditLogRepository.cs
|
|
|
@ -40,5 +40,9 @@ namespace Volo.Abp.AuditLogging |
|
|
|
bool? hasException = null, |
|
|
|
HttpStatusCode? httpStatusCode = null, |
|
|
|
CancellationToken cancellationToken = default); |
|
|
|
|
|
|
|
Task<Dictionary<DateTime, double>> GetAverageExecutionDurationPerDayAsync( |
|
|
|
DateTime startDate, |
|
|
|
DateTime endDate); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@ -122,6 +122,18 @@ namespace Volo.Abp.AuditLogging.EntityFrameworkCore |
|
|
|
.WhereIf(minExecutionDuration != null && minExecutionDuration.Value > 0, auditLog => auditLog.ExecutionDuration >= minExecutionDuration); |
|
|
|
} |
|
|
|
|
|
|
|
public async Task<Dictionary<DateTime, double>> GetAverageExecutionDurationPerDayAsync(DateTime startDate, DateTime endDate) |
|
|
|
{ |
|
|
|
var result = await DbSet.AsNoTracking() |
|
|
|
.Where(a => a.ExecutionTime < endDate.AddDays(1) && a.ExecutionTime > startDate) |
|
|
|
.OrderBy(t => t.ExecutionTime) |
|
|
|
.GroupBy(t => new { t.ExecutionTime.Date }) |
|
|
|
.Select(g => new { Day = g.Min(t => t.ExecutionTime), avgExecutionTime = g.Average(t => t.ExecutionDuration) }) |
|
|
|
.ToListAsync(); |
|
|
|
|
|
|
|
return result.ToDictionary(element => element.Day.ClearTime(), element => element.avgExecutionTime); |
|
|
|
} |
|
|
|
|
|
|
|
public override IQueryable<AuditLog> WithDetails() |
|
|
|
{ |
|
|
|
return GetQueryable().IncludeDetails(); |
|
|
|
|
|
|
|
@ -120,5 +120,18 @@ namespace Volo.Abp.AuditLogging.MongoDB |
|
|
|
.WhereIf(maxDuration != null && maxDuration > 0, auditLog => auditLog.ExecutionDuration <= maxDuration) |
|
|
|
.WhereIf(minDuration != null && minDuration > 0, auditLog => auditLog.ExecutionDuration >= minDuration); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public async Task<Dictionary<DateTime, double>> GetAverageExecutionDurationPerDayAsync(DateTime startDate, DateTime endDate) |
|
|
|
{ |
|
|
|
var result = await GetMongoQueryable() |
|
|
|
.Where(a => a.ExecutionTime < endDate.AddDays(1) && a.ExecutionTime > startDate) |
|
|
|
.OrderBy(t => t.ExecutionTime) |
|
|
|
.GroupBy(t => new { t.ExecutionTime.Date }) |
|
|
|
.Select(g => new { Day = g.Min(t => t.ExecutionTime), avgExecutionTime = g.Average(t => t.ExecutionDuration) }) |
|
|
|
.ToListAsync(); |
|
|
|
|
|
|
|
return result.ToDictionary(element => element.Day.ClearTime(), element => element.avgExecutionTime); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|