Правки по результатам ревью (частично)

This commit is contained in:
Оля Бизюкова 2024-12-03 17:36:41 +05:00
parent e98cd7d6e9
commit ca816da076
10 changed files with 14 additions and 73 deletions

View File

@ -137,7 +137,7 @@ public class ChangeLogController : ControllerBase, IChangeLogApi
DateTimeOffset dateEnd, DateTimeOffset dateEnd,
CancellationToken token = default) CancellationToken token = default)
{ {
var result = await repository.GetChangeLogForDate(idDiscriminator, dateBegin, dateEnd, token); var result = await repository.GetChangeLogForInterval(idDiscriminator, dateBegin, dateEnd, token);
return Ok(result); return Ok(result);
} }

View File

@ -11,7 +11,6 @@ public interface IChangeLogClient
{ {
private const string BaseRoute = "/api/ChangeLog"; private const string BaseRoute = "/api/ChangeLog";
//[Get($"{BaseRoute}/current")]
/// <summary> /// <summary>
/// Импорт с заменой: удаление старых строк и добавление новых /// Импорт с заменой: удаление старых строк и добавление новых
/// </summary> /// </summary>
@ -39,7 +38,7 @@ public interface IChangeLogClient
/// <param name="dateEnd"></param> /// <param name="dateEnd"></param>
/// <returns></returns> /// <returns></returns>
[Get($"{BaseRoute}/history")] [Get($"{BaseRoute}/history")]
Task<IApiResponse<IEnumerable<ChangeLogDto>>> GetChangeLogForDate(Guid idDiscriminator, DateTimeOffset dateBegin, DateTimeOffset dateEnd); Task<IApiResponse<IEnumerable<ChangeLogDto>>> GetChangeLogForInterval(Guid idDiscriminator, DateTimeOffset dateBegin, DateTimeOffset dateEnd);
/// <summary> /// <summary>
/// Добавить одну запись /// Добавить одну запись

View File

@ -97,7 +97,7 @@ public class ChangeLogControllerTest : BaseIntegrationTest
var dateBegin = DateTimeOffset.UtcNow.AddDays(-1); var dateBegin = DateTimeOffset.UtcNow.AddDays(-1);
var dateEnd = DateTimeOffset.UtcNow.AddDays(1); var dateEnd = DateTimeOffset.UtcNow.AddDays(1);
var changeLogResult = await client.GetChangeLogForDate(idDiscriminator, dateBegin, dateEnd); var changeLogResult = await client.GetChangeLogForInterval(idDiscriminator, dateBegin, dateEnd);
Assert.Equal(HttpStatusCode.OK, changeLogResult.StatusCode); Assert.Equal(HttpStatusCode.OK, changeLogResult.StatusCode);
Assert.NotNull(changeLogResult.Content); Assert.NotNull(changeLogResult.Content);
@ -254,7 +254,7 @@ public class ChangeLogControllerTest : BaseIntegrationTest
[Theory] [Theory]
[InlineData(5, -15, 15, -20, 20, 10)] [InlineData(5, -15, 15, -20, 20, 10)]
[InlineData(5, -15, -10, -16, -9, 5)] [InlineData(5, -15, -10, -16, -9, 5)]
public async Task GetChangeLogForDate_returns_success( public async Task GetChangeLogForInterval_returns_success(
int insertedCount, int insertedCount,
int leftCreationFromCurrentDate, int leftCreationFromCurrentDate,
int rightCreationFromCurrentDate, int rightCreationFromCurrentDate,
@ -280,7 +280,7 @@ public class ChangeLogControllerTest : BaseIntegrationTest
//act //act
var dateBegin = DateTimeOffset.UtcNow.AddDays(leftPointFromCurrentDate); var dateBegin = DateTimeOffset.UtcNow.AddDays(leftPointFromCurrentDate);
var dateEnd = DateTimeOffset.UtcNow.AddDays(rightPointFromCurrentDate); var dateEnd = DateTimeOffset.UtcNow.AddDays(rightPointFromCurrentDate);
var result = await client.GetChangeLogForDate(idDiscriminator, dateBegin, dateEnd); var result = await client.GetChangeLogForInterval(idDiscriminator, dateBegin, dateEnd);
//assert //assert
Assert.Equal(HttpStatusCode.OK, result.StatusCode); Assert.Equal(HttpStatusCode.OK, result.StatusCode);

View File

@ -153,7 +153,7 @@ public class ChangeLogRepository : IChangeLogRepository
return query; return query;
} }
public async Task<IEnumerable<ChangeLogDto>> GetChangeLogForDate(Guid idDiscriminator, DateTimeOffset dateBegin, DateTimeOffset dateEnd, CancellationToken token) public async Task<IEnumerable<ChangeLogDto>> GetChangeLogForInterval(Guid idDiscriminator, DateTimeOffset dateBegin, DateTimeOffset dateEnd, CancellationToken token)
{ {
var query = db.Set<ChangeLog>().Where(s => s.IdDiscriminator == idDiscriminator); var query = db.Set<ChangeLog>().Where(s => s.IdDiscriminator == idDiscriminator);
@ -177,8 +177,8 @@ public class ChangeLogRepository : IChangeLogRepository
{ {
var result = new PaginationContainer<DataWithWellDepthAndSectionDto> var result = new PaginationContainer<DataWithWellDepthAndSectionDto>
{ {
Skip = request.Skip ?? 0, Skip = request.Skip,
Take = request.Take ?? 32, Take = request.Take,
Items = Enumerable.Empty<DataWithWellDepthAndSectionDto>(), Items = Enumerable.Empty<DataWithWellDepthAndSectionDto>(),
Count = await query.CountAsync(token) Count = await query.CountAsync(token)
}; };

View File

@ -36,7 +36,7 @@ public class ChangeLogDto
public DateTimeOffset? Obsolete { get; set; } public DateTimeOffset? Obsolete { get; set; }
/// <summary> /// <summary>
/// Ключ следующей записи /// Ключ заменившей записи
/// </summary> /// </summary>
public Guid? IdNext { get; set; } public Guid? IdNext { get; set; }

View File

@ -11,11 +11,6 @@ namespace Persistence.Models;
/// </summary> /// </summary>
public class DataWithWellDepthAndSectionDto public class DataWithWellDepthAndSectionDto
{ {
public DataWithWellDepthAndSectionDto()
{
}
/// <summary> /// <summary>
/// Ключ записи /// Ключ записи
/// </summary> /// </summary>
@ -39,5 +34,5 @@ public class DataWithWellDepthAndSectionDto
/// <summary> /// <summary>
/// Объект записи /// Объект записи
/// </summary> /// </summary>
public required IDictionary<string, object> Value { get; set; } = default!; public required IDictionary<string, object> Value { get; set; }
} }

View File

@ -1,42 +0,0 @@
namespace Persistence.Models;
/// <summary>
/// Часть записи описывающая изменение
/// </summary>
public interface IChangeLogDto
{
///// <summary>
///// Ид записи
///// </summary>
//public int Id { get; set; }
///// <summary>
///// Автор изменения
///// </summary>
//public int IdAuthor { get; set; }
///// <summary>
///// Редактор
///// </summary>
//public int? IdEditor { get; set; }
///// <summary>
///// Дата создания записи
///// </summary>
//public DateTimeOffset Creation { get; set; }
///// <summary>
///// Дата устаревания (например при удалении)
///// </summary>
//public DateTimeOffset? Obsolete { get; set; }
///// <summary>
///// Id заменяющей записи
///// </summary>
//public int? IdNext { get; set; }
///// <summary>
///// Значение
///// </summary>
//public object Value { get; set; }
}

View File

@ -1,11 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Persistence.Models;
public class ProcessMapRotorDto : IChangeLogDto
{
public string Caption { get; set; }
}

View File

@ -9,17 +9,17 @@ public class Request
/// <summary> /// <summary>
/// Кол-во записей пропущенных с начала таблицы в запросе от api /// Кол-во записей пропущенных с начала таблицы в запросе от api
/// </summary> /// </summary>
public int? Skip { get; set; } public int Skip { get; set; } = 0;
/// <summary> /// <summary>
/// Кол-во записей в запросе от api /// Кол-во записей в запросе от api
/// </summary> /// </summary>
public int? Take { get; set; } public int Take { get; set; } = 32;
/// <summary> /// <summary>
/// Сортировки: /// Сортировки:
/// Содержат список названий полей сортировки /// Содержат список названий полей сортировки
/// Указать направление сортировки можно через пробел "asc" или "desc" /// Указать направление сортировки можно через пробел "asc" или "desc"
/// </summary> /// </summary>
public string? SortSettings { get; set; } = string.Empty; public string? SortSettings { get; set; }
} }

View File

@ -75,7 +75,7 @@ public interface IChangeLogRepository : ISyncWithDiscriminatorRepository<DataWit
/// <param name="dateEnd"></param> /// <param name="dateEnd"></param>
/// <param name="token"></param> /// <param name="token"></param>
/// <returns></returns> /// <returns></returns>
Task<IEnumerable<ChangeLogDto>> GetChangeLogForDate(Guid idDiscriminator, DateTimeOffset dateBegin, DateTimeOffset dateEnd, CancellationToken token); Task<IEnumerable<ChangeLogDto>> GetChangeLogForInterval(Guid idDiscriminator, DateTimeOffset dateBegin, DateTimeOffset dateEnd, CancellationToken token);
/// <summary> /// <summary>
/// Получение списка дат, в которые происходили изменения (день, месяц, год, без времени) /// Получение списка дат, в которые происходили изменения (день, месяц, год, без времени)