Оптимизация получения элементов Wits

This commit is contained in:
Степанов Дмитрий 2024-04-10 09:09:48 +03:00
parent 979ed91e78
commit a91d4888e6

View File

@ -12,6 +12,7 @@ using System.Diagnostics;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using AsbCloudApp.Exceptions;
using AsbCloudApp.Requests;
using Mapster;
@ -19,7 +20,7 @@ namespace AsbCloudInfrastructure.Repository
{
public class GtrWitsRepository : IGtrRepository
{
private static IDictionary<(int, int), string> WitsParameters = new Dictionary<(int, int), string>
private static IDictionary<(int IdRecord, int IdItem), string> WitsParameters = new Dictionary<(int, int), string>
{
{ (1, 8), nameof(GtrWitsDto.DEPTBITM) },
{ (1, 10), nameof(GtrWitsDto.DEPTMEAS) },
@ -90,8 +91,10 @@ namespace AsbCloudInfrastructure.Repository
if (telemetry is null)
return Enumerable.Empty<GtrWitsDto>();
var timezone = telemetryService.GetTimezone(telemetry.Id);
var timezoneOffset = TimeSpan.FromHours(timezone.Hours);
if (telemetry.TimeZone is null)
throw new ArgumentInvalidException(nameof(idWell),$"Telemetry id: {telemetry.Id} can't find timezone");
var timezoneOffset = TimeSpan.FromHours(telemetry.TimeZone.Hours);
var query = BuildQuery<TEntity, TType>(telemetry.Id, request);
@ -100,7 +103,10 @@ namespace AsbCloudInfrastructure.Repository
var interval = TimeSpan.FromSeconds(10);
var idsRecord = WitsParameters.Select(p => p.Key.IdRecord);
var entities = await query
.Where(e => idsRecord.Contains(e.IdRecord))
.OrderBy(e => e.DateTime)
.AsNoTracking()
.ToArrayAsync(token);