Исправление бага, при котором метод GetCurrent возвращал лишние значения
All checks were successful
Unit tests / test (push) Successful in 1m14s

This commit is contained in:
Шибалкин Александр 2025-01-17 10:50:36 +05:00
parent 5497b89c3b
commit 2a0fa0f3f9

View File

@ -16,14 +16,19 @@ namespace DD.Persistence.Repository.Repositories
protected virtual IQueryable<Setpoint> GetQueryReadOnly() => db.Set<Setpoint>();
public async Task<IEnumerable<SetpointValueDto>> GetCurrent(IEnumerable<Guid> setpointKeys, CancellationToken token)
public async Task<IEnumerable<SetpointValueDto>> GetCurrent(
IEnumerable<Guid> setpointKeys,
CancellationToken token)
{
var query = GetQueryReadOnly();
var entities = await query
.Where(e => setpointKeys.Contains(e.Key))
.GroupBy(e => e.Key)
.Select(g => g.OrderByDescending(x => x.Created).FirstOrDefault())
.ToArrayAsync(token);
var dtos = entities.Select(e => e.Adapt<SetpointValueDto>());
var dtos = entities.Select(e => e.Adapt<SetpointValueDto>());
return dtos;
}