small correction

This commit is contained in:
eugeniy_ivanov 2023-04-14 00:40:38 +05:00
parent 55e17f6955
commit 9b1b1f9736

View File

@ -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<WitsItemFloat>();
if (fullDataCount == 0)
return Enumerable.Empty<ItemRecord>();
//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<ItemRecord>();
var items = entities.Select(e => new ItemRecord
{
IdRecord = e.IdRecord,