Правки по результатам ревью
Some checks failed
Unit tests / test (push) Failing after 1m2s

This commit is contained in:
Roman Efremov 2025-01-22 15:16:24 +05:00
parent e981b835a5
commit 3262201973
5 changed files with 9 additions and 11 deletions

View File

@ -35,7 +35,7 @@ public class TimestampedValuesController : ControllerBase
{
var result = await timestampedValuesRepository.AddRange(discriminatorId, dtos, token);
return Ok(result);
return CreatedAtAction(nameof(AddRange), result);
}
/// <summary>

View File

@ -12,13 +12,13 @@ public abstract class BaseClient
this.logger = logger;
}
public async Task<T> ExecuteGetResponse<T>(Func<Task<IApiResponse<T>>> getMethod, CancellationToken token)
public async Task<T?> ExecuteGetResponse<T>(Func<Task<IApiResponse<T>>> getMethod, CancellationToken token)
{
var response = await getMethod.Invoke().WaitAsync(token);
if (response.IsSuccessStatusCode)
{
return response.Content!;
return response.Content;
}
var exception = response.GetPersistenceException();

View File

@ -96,7 +96,6 @@ public interface ITimestampedValuesClient : IDisposable
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="idDiscriminator"></param>
/// <param name="columnNames"></param>
/// <param name="take"></param>
/// <param name="token"></param>
/// <returns></returns>

View File

@ -92,6 +92,7 @@ public class TimestampedValuesRepository : ITimestampedValuesRepository
return result;
}
// ToDo: прореживание должно осуществляться до материализации
public async virtual Task<IEnumerable<Tuple<DateTimeOffset, object[]>>> GetResampledData(
Guid discriminatorId,
DateTimeOffset dateBegin,

View File

@ -22,6 +22,7 @@ public class TimestampedValuesService : ITimestampedValuesService
/// <inheritdoc/>
public async Task<int> AddRange(Guid discriminatorId, IEnumerable<TimestampedValuesDto> dtos, CancellationToken token)
{
// ToDo: реализовать без foreach
foreach (var dto in dtos)
{
var keys = dto.Values.Keys.ToArray();
@ -132,13 +133,10 @@ public class TimestampedValuesService : ITimestampedValuesService
};
var identity = systemSpecification!.PropNames;
for (var i = 0; i < identity.Count(); i++)
{
var key = identity[i];
var value = entity.Item2[i];
dto.Values.Add(key, value);
}
var indexedIdentity = identity
.Select((value, index) => new { index, value });
dto.Values = indexedIdentity
.ToDictionary(x => x.value, x => entity.Item2[x.index]);
return dto;
});