#15287262 Сделал OperationStatRequest.DurationMinutes* double

This commit is contained in:
Frolov-Nikita 2023-10-04 09:15:28 +05:00
parent 2b400012c6
commit 6eb118e9f6
No known key found for this signature in database
GPG Key ID: 719E3386D12B0760
2 changed files with 130 additions and 133 deletions

View File

@ -5,9 +5,8 @@ namespace AsbCloudApp.Requests
/// <summary> /// <summary>
/// Параметры фильтра операции /// Параметры фильтра операции
/// </summary> /// </summary>
public class OperationStatRequest : RequestBase public class OperationStatRequest
{ {
/// <summary> /// <summary>
/// Дата начала операции в UTC /// Дата начала операции в UTC
/// </summary> /// </summary>
@ -18,17 +17,14 @@ namespace AsbCloudApp.Requests
/// </summary> /// </summary>
public DateTime? DateEndUTC { get; set; } public DateTime? DateEndUTC { get; set; }
/// <summary> /// <summary>
/// Минимальная продолжительность операции, мин /// Минимальная продолжительность операции, мин
/// </summary> /// </summary>
public int? DurationMinutesMin { get; set; } public double? DurationMinutesMin { get; set; }
/// <summary> /// <summary>
/// Максимальная продолжительность операции, мин /// Максимальная продолжительность операции, мин
/// </summary> /// </summary>
public int? DurationMinutesMax { get; set; } public double? DurationMinutesMax { get; set; }
} }
} }

View File

@ -9,11 +9,12 @@ using System.Linq;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace AsbCloudInfrastructure.Services namespace AsbCloudInfrastructure.Services;
public class SlipsStatService : ISlipsStatService
{ {
public class SlipsStatService : ISlipsStatService
{
private readonly IAsbCloudDbContext db; private readonly IAsbCloudDbContext db;
public SlipsStatService(IAsbCloudDbContext db) public SlipsStatService(IAsbCloudDbContext db)
{ {
this.db = db; this.db = db;
@ -84,13 +85,14 @@ namespace AsbCloudInfrastructure.Services
if (request.DurationMinutesMin.HasValue) if (request.DurationMinutesMin.HasValue)
{ {
var durationMinutesMin = new TimeSpan(0, request.DurationMinutesMin.Value, 0); var durationMinutesMin = TimeSpan.FromMinutes(request.DurationMinutesMin.Value);
detectedOperationsQuery = detectedOperationsQuery detectedOperationsQuery = detectedOperationsQuery
.Where(o => o.DateEnd - o.DateStart >= durationMinutesMin); .Where(o => o.DateEnd - o.DateStart >= durationMinutesMin);
} }
if (request.DurationMinutesMax.HasValue) if (request.DurationMinutesMax.HasValue)
{ {
var durationMinutesMax = new TimeSpan(0, request.DurationMinutesMax.Value, 0); var durationMinutesMax = TimeSpan.FromMinutes(request.DurationMinutesMax.Value);
detectedOperationsQuery = detectedOperationsQuery detectedOperationsQuery = detectedOperationsQuery
.Where(o => o.DateEnd - o.DateStart <= durationMinutesMax); .Where(o => o.DateEnd - o.DateStart <= durationMinutesMax);
} }
@ -158,5 +160,4 @@ namespace AsbCloudInfrastructure.Services
return stats; return stats;
} }
}
} }