diff --git a/AsbCloudInfrastructure/Repository/GtrWitsRepository.cs b/AsbCloudInfrastructure/Repository/GtrWitsRepository.cs index 0176d4bd..ce12d6fe 100644 --- a/AsbCloudInfrastructure/Repository/GtrWitsRepository.cs +++ b/AsbCloudInfrastructure/Repository/GtrWitsRepository.cs @@ -116,21 +116,21 @@ namespace AsbCloudInfrastructure.Repository , CancellationToken token) where T: notnull { - //if (filterByDateEnd) - // query = query.Where(d => d.DateTime <= dateEnd); + if (filterByDateEnd) + query = query.Where(d => d.DateTime <= dateEnd); - //var fullDataCount = await query.CountAsync(token) - // .ConfigureAwait(false); + var fullDataCount = await query.CountAsync(token) + .ConfigureAwait(false); - //if (fullDataCount == 0) - // return Enumerable.Empty(); + if (fullDataCount == 0) + return Enumerable.Empty(); - //if (fullDataCount > 1.75 * approxPointsCount) - //{ - // var m = (int)Math.Round(1d * fullDataCount / approxPointsCount); - // if (m > 1) - // query = query.Where((d) => (((d.DateTime.DayOfYear * 24 + d.DateTime.Hour) * 60 + d.DateTime.Minute) * 60 + d.DateTime.Second) % m == 0); - //} + if (fullDataCount > 1.75 * approxPointsCount) + { + var m = (int)Math.Round(1d * fullDataCount / approxPointsCount); + if (m > 1) + query = query.Where((d) => (((d.DateTime.DayOfYear * 24 + d.DateTime.Hour) * 60 + d.DateTime.Minute) * 60 + d.DateTime.Second) % m == 0); + } var entities = await query .Where(d => d.DateTime >= dateBeginUtc) diff --git a/AsbCloudWebApi/Controllers/SAUB/GtrWitsController.cs b/AsbCloudWebApi/Controllers/SAUB/GtrWitsController.cs index 198b8b10..094b7319 100644 --- a/AsbCloudWebApi/Controllers/SAUB/GtrWitsController.cs +++ b/AsbCloudWebApi/Controllers/SAUB/GtrWitsController.cs @@ -46,20 +46,20 @@ namespace AsbCloudWebApi.Controllers.SAUB /// Токен завершения задачи /// [HttpGet("{idWell}")] - // [Permission] + [Permission] public async Task>> GetDataAsync(int idWell, DateTime begin = default, int intervalSec = 600, int approxPointsCount = 1024, CancellationToken token = default) { - //int? idCompany = User.GetCompanyId(); + int? idCompany = User.GetCompanyId(); - //if (idCompany is null) - // return Forbid(); + if (idCompany is null) + return Forbid(); - //bool isCompanyOwnsWell = await wellService.IsCompanyInvolvedInWellAsync((int)idCompany, - // idWell, token).ConfigureAwait(false); + bool isCompanyOwnsWell = await wellService.IsCompanyInvolvedInWellAsync((int)idCompany, + idWell, token).ConfigureAwait(false); - //if (!isCompanyOwnsWell) - // return Forbid(); + if (!isCompanyOwnsWell) + return Forbid(); var content = await gtrRepository.GetAsync(idWell, begin, intervalSec, approxPointsCount, token).ConfigureAwait(false);