diff --git a/AsbCloudInfrastructure/Repository/GtrWitsRepository.cs b/AsbCloudInfrastructure/Repository/GtrWitsRepository.cs index 18a8b7eb..15128a49 100644 --- a/AsbCloudInfrastructure/Repository/GtrWitsRepository.cs +++ b/AsbCloudInfrastructure/Repository/GtrWitsRepository.cs @@ -71,8 +71,8 @@ namespace AsbCloudInfrastructure.Repository var groupRecordDate = (recordAllFloat.Union(recordAllInt)).Union(recordAllString) .GroupBy(g => new { - IdRecord = g.IdRecord, - Date = g.Date + g.IdRecord, + g.Date }).ToList(); var dtos = groupRecordDate.Select(g => new WitsRecordDto { @@ -82,8 +82,7 @@ namespace AsbCloudInfrastructure.Repository Items = g.Select(r => new { Key = r.IdItem, Value = r.Item - }).ToList().ToDictionary(x => x.Key, x => x.Value) - + }).ToList().ToDictionary(x => x.Key, x => x.Value) }); return dtos; } @@ -119,29 +118,28 @@ namespace AsbCloudInfrastructure.Repository DateTimeOffset dateEnd, bool filterByDateEnd, int approxPointsCount, double timezoneHours , CancellationToken token) { - //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 .OrderBy(d => d.DateTime) .AsNoTracking() .ToListAsync(token) .ConfigureAwait(false); - if (entities is null) - return Enumerable.Empty(); + var items = entities.Select(e => new ItemRecord { IdRecord = e.IdRecord,