forked from ddrilling/AsbCloudServer
корректировка метода получения диапазона дат по наработкам подсистем,
добавление метода в интерфейс ISubsystemOperationTimeService
This commit is contained in:
parent
0b419ec3c6
commit
87805a7104
@ -36,7 +36,15 @@ namespace AsbCloudApp.Services.Subsystems
|
||||
/// <param name="request"></param>
|
||||
/// <param name="token"></param>
|
||||
/// <returns></returns>
|
||||
Task<IEnumerable<SubsystemOperationTimeDto>?> GetOperationTimeAsync(SubsystemOperationTimeRequest request, CancellationToken token);
|
||||
Task<IEnumerable<SubsystemOperationTimeDto>?> GetOperationTimeAsync(SubsystemOperationTimeRequest request, CancellationToken token);
|
||||
|
||||
/// <summary>
|
||||
/// Временной диапазон за который есть статистика работы подсистем
|
||||
/// </summary>
|
||||
/// <param name="idSubsystem"></param>
|
||||
/// <param name="token"></param>
|
||||
/// <returns></returns>
|
||||
Task<IEnumerable<SubsystemOperationTimeDto>?> GetDateRangeOperationTimeAsync(int idSubsystem, CancellationToken token);
|
||||
}
|
||||
#nullable disable
|
||||
}
|
||||
|
@ -185,9 +185,9 @@ namespace AsbCloudInfrastructure.Services.Subsystems
|
||||
|
||||
}
|
||||
|
||||
private (DateTimeOffset, DateTimeOffset) GetDateRangeOperationTime(int idSubsystem)
|
||||
private async Task<(DateTimeOffset, DateTimeOffset)?> GetDateRangeOperationTime(int idSubsystem, CancellationToken token)
|
||||
{
|
||||
var dateRange = db.SubsystemOperationTimes
|
||||
var dateRange = await db.SubsystemOperationTimes
|
||||
.Where(o => o.Id == idSubsystem)
|
||||
.GroupBy(o => o.IdSubsystem)
|
||||
.Select(g => new
|
||||
@ -195,7 +195,11 @@ namespace AsbCloudInfrastructure.Services.Subsystems
|
||||
DateFirst = g.Min(o => o.DateStart),
|
||||
DateLast = g.Max(o => o.DateEnd)
|
||||
})
|
||||
.FirstOrDefault();
|
||||
.FirstOrDefaultAsync(token);
|
||||
if (dateRange == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
(DateTimeOffset dateFirst, DateTimeOffset dateLast) result = (dateRange.DateFirst, dateRange.DateLast);
|
||||
return result;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user