diff --git a/AsbCloudApp/Services/IDataSaubStatService.cs b/AsbCloudApp/Services/IDataSaubStatService.cs index 38e9dece..f72d4480 100644 --- a/AsbCloudApp/Services/IDataSaubStatService.cs +++ b/AsbCloudApp/Services/IDataSaubStatService.cs @@ -1,7 +1,4 @@ -using AsbCloudApp.Data; -using AsbCloudApp.Requests; using System; -using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; @@ -13,16 +10,15 @@ namespace AsbCloudApp.Services public interface IDataSaubStatService { /// - /// Создание записей таблицы DataSaubStat + /// Расчет статистики DataSaubStat /// - /// - /// Количество дней, которые необходимо вычесть из текущей даты для формирования начальной даты - /// сбора данных по телеметрии + /// + /// Количество дней за которые должны были приходить данные, чтобы телеметрия попала в обработку. /// /// /// /// - Task CreateStatAsync(int gap, Action onProgressCallback, CancellationToken token); + Task CreateStatAsync(int lastDaysFilter, Action onProgressCallback, CancellationToken token); } } diff --git a/AsbCloudInfrastructure/Services/DataSaubStatService.cs b/AsbCloudInfrastructure/Services/DataSaubStatService.cs index 509615a2..e54a380d 100644 --- a/AsbCloudInfrastructure/Services/DataSaubStatService.cs +++ b/AsbCloudInfrastructure/Services/DataSaubStatService.cs @@ -33,11 +33,11 @@ namespace AsbCloudInfrastructure.Services this.detectedOperationRepository = detectedOperationRepository; } - public async Task CreateStatAsync(int gap, Action onProgressCallback, CancellationToken token) + public async Task CreateStatAsync(int lastDaysFilter, Action onProgressCallback, CancellationToken token) { var cacheRequest = new TelemetryDataRequest() { - GeDate = DateTime.UtcNow.AddDays(-gap) + GeDate = DateTime.UtcNow.AddDays(-lastDaysFilter) }; var idTelemetries = telemetryDataCache.GetIds(cacheRequest).ToArray(); @@ -52,7 +52,7 @@ namespace AsbCloudInfrastructure.Services var lastDate = stats.FirstOrDefault(s => s.IdTelemetry == idTelemetry)?.DateEnd.ToUniversalTime() ?? DateTimeOffset.UnixEpoch; var statsCount = await CreateStatForTelemetryFromDate(idTelemetry, lastDate, token); if(onProgressCallback != null) - onProgressCallback($"Calculate stat for telemetry: {idTelemetry}; from {lastDate}; results count: {statsCount};", i * 1d / idTelemetries.Length); + onProgressCallback($"Calculate stat for telemetry: {idTelemetry}; from {lastDate}; results count: {statsCount};", 1d * i / idTelemetries.Length); } } diff --git a/AsbCloudWebApi.Tests/Services/DataSaubStatServiceTest.cs b/AsbCloudWebApi.Tests/Services/DataSaubStatServiceTest.cs index ed03769e..6d65a1f2 100644 --- a/AsbCloudWebApi.Tests/Services/DataSaubStatServiceTest.cs +++ b/AsbCloudWebApi.Tests/Services/DataSaubStatServiceTest.cs @@ -248,7 +248,7 @@ public class DataSaubStatServiceTest { //assert Assert.NotNull(percent); - Assert.InRange((double)percent, 0.0, 100.0); + Assert.InRange(percent.Value, 0.0, 1.0); }; //act @@ -309,7 +309,7 @@ public class DataSaubStatServiceTest { //assert Assert.NotNull(percent); - Assert.InRange((double)percent, 0.0, 100.0); + Assert.InRange(percent.Value, 0.0, 1.0); }; //act