Fix well service

This commit is contained in:
Степанов Дмитрий 2024-04-12 09:47:17 +03:00
parent 7c88fb23de
commit b734ed929e
2 changed files with 8 additions and 7 deletions

View File

@ -148,17 +148,18 @@ namespace AsbCloudInfrastructure.Services.SAUB
{ {
if (!caches.TryGetValue(idTelemetry, out TelemetryDataCacheItem? cacheItem)) if (!caches.TryGetValue(idTelemetry, out TelemetryDataCacheItem? cacheItem))
return null; return null;
var from = cacheItem.FirstByDate?.DateTime;
if (!cacheItem.LastData.Any()) if (!cacheItem.LastData.Any())
return null; return null;
var from = cacheItem.FirstByDate.DateTime;
var to = cacheItem.LastData[^1].DateTime; var to = cacheItem.LastData[^1].DateTime;
from = from ?? cacheItem.LastData[0].DateTime;
return new DatesRangeDto { return new DatesRangeDto
From = from.Value.ToUtcDateTimeOffset(cacheItem.TimezoneHours), {
To = to.ToUtcDateTimeOffset(cacheItem.TimezoneHours) }; From = new DateTimeOffset(from, TimeSpan.FromHours(cacheItem.TimezoneHours)),
To = new DateTimeOffset(to, TimeSpan.FromHours(cacheItem.TimezoneHours))
};
} }
public DatesRangeDto? GetOrDefaultCachedDateRange(int idTelemetry) public DatesRangeDto? GetOrDefaultCachedDateRange(int idTelemetry)

View File

@ -71,7 +71,7 @@ namespace AsbCloudInfrastructure.Services
return DateTimeOffset.MinValue; return DateTimeOffset.MinValue;
var datesRange = telemetryService.GetDatesRange(well.IdTelemetry.Value); var datesRange = telemetryService.GetDatesRange(well.IdTelemetry.Value);
return datesRange.To.DateTime; return datesRange.To;
} }
/// <inheritdoc/> /// <inheritdoc/>