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

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,
CancellationToken token = default)
{
var result = await repository.GetChangeLogForDate(idDiscriminator, dateBegin, dateEnd, token);
var result = await repository.GetChangeLogForInterval(idDiscriminator, dateBegin, dateEnd, token);
return Ok(result);
}

View File

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

View File

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

View File

@ -153,7 +153,7 @@ public class ChangeLogRepository : IChangeLogRepository
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);
@ -177,8 +177,8 @@ public class ChangeLogRepository : IChangeLogRepository
{
var result = new PaginationContainer<DataWithWellDepthAndSectionDto>
{
Skip = request.Skip ?? 0,
Take = request.Take ?? 32,
Skip = request.Skip,
Take = request.Take,
Items = Enumerable.Empty<DataWithWellDepthAndSectionDto>(),
Count = await query.CountAsync(token)
};

View File

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

View File

@ -11,11 +11,6 @@ namespace Persistence.Models;
/// </summary>
public class DataWithWellDepthAndSectionDto
{
public DataWithWellDepthAndSectionDto()
{
}
/// <summary>
/// Ключ записи
/// </summary>
@ -39,5 +34,5 @@ public class DataWithWellDepthAndSectionDto
/// <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>
/// Кол-во записей пропущенных с начала таблицы в запросе от api
/// </summary>
public int? Skip { get; set; }
public int Skip { get; set; } = 0;
/// <summary>
/// Кол-во записей в запросе от api
/// </summary>
public int? Take { get; set; }
public int Take { get; set; } = 32;
/// <summary>
/// Сортировки:
/// Содержат список названий полей сортировки
/// Указать направление сортировки можно через пробел "asc" или "desc"
/// </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="token"></param>
/// <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>
/// Получение списка дат, в которые происходили изменения (день, месяц, год, без времени)