#384 Авторизации + получение id пользователя в контроллерах #3
@ -19,24 +19,32 @@ public class TimeSeriesController<TDto> : ControllerBase, ITimeSeriesDataApi<TDt
|
|||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
public async Task<IActionResult> GetAsync(DateTimeOffset dateBegin, DateTimeOffset dateEnd, CancellationToken token)
|
public async Task<IActionResult> Get(DateTimeOffset dateBegin, CancellationToken token)
|
||||||
{
|
{
|
||||||
var result = await this.timeSeriesDataRepository.GetAsync(dateBegin, dateEnd, token);
|
var result = await this.timeSeriesDataRepository.GetGtDate(dateBegin, token);
|
||||||
return Ok(result);
|
return Ok(result);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet("datesRange")]
|
[HttpGet("datesRange")]
|
||||||
public async Task<IActionResult> GetDatesRangeAsync(CancellationToken token)
|
public async Task<IActionResult> GetDatesRange(CancellationToken token)
|
||||||
{
|
{
|
||||||
var result = await this.timeSeriesDataRepository.GetDatesRangeAsync(token);
|
var result = await this.timeSeriesDataRepository.GetDatesRange(token);
|
||||||
|
return Ok(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet("resampled")]
|
||||||
|
public async Task<IActionResult> GetResampledData(DateTimeOffset dateBegin, double intervalSec = 600d, int approxPointsCount = 1024, CancellationToken token = default)
|
||||||
|
{
|
||||||
|
var result = await this.timeSeriesDataRepository.GetResampledData(dateBegin, intervalSec, approxPointsCount, token);
|
||||||
return Ok(result);
|
return Ok(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public async Task<IActionResult> InsertRangeAsync(IEnumerable<TDto> dtos, CancellationToken token)
|
public async Task<IActionResult> InsertRange(IEnumerable<TDto> dtos, CancellationToken token)
|
||||||
{
|
{
|
||||||
var result = await this.timeSeriesDataRepository.InsertRange(dtos, token);
|
var result = await this.timeSeriesDataRepository.InsertRange(dtos, token);
|
||||||
return Ok(result);
|
return Ok(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,13 @@
|
|||||||
|
|
||||||
|
using Persistence.Models;
|
||||||
|
|
||||||
namespace Persistence.API;
|
namespace Persistence.API;
|
||||||
|
|
||||||
public class Program
|
public class Program
|
||||||
{
|
{
|
||||||
public static void Main(string[] args)
|
public static void Main(string[] args)
|
||||||
{
|
{
|
||||||
|
|
||||||
var host = CreateHostBuilder(args).Build();
|
var host = CreateHostBuilder(args).Build();
|
||||||
Startup.BeforeRunHandler(host);
|
Startup.BeforeRunHandler(host);
|
||||||
host.Run();
|
host.Run();
|
||||||
|
@ -33,6 +33,11 @@ public class Startup
|
|||||||
|
|
||||||
app.UseRouting();
|
app.UseRouting();
|
||||||
|
|
||||||
|
if (env.IsDevelopment())
|
||||||
|
{
|
||||||
|
app.UseDeveloperExceptionPage();
|
||||||
|
}
|
||||||
|
|
||||||
app.UseAuthentication();
|
app.UseAuthentication();
|
||||||
app.UseAuthorization();
|
app.UseAuthorization();
|
||||||
|
|
||||||
|
@ -1,13 +1,22 @@
|
|||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using Persistence.Models;
|
||||||
using Refit;
|
using Refit;
|
||||||
|
|
||||||
namespace Persistence.Client.Clients;
|
namespace Persistence.Client.Clients;
|
||||||
public interface ITimeSeriesClient<TDto>
|
public interface ITimeSeriesClient<TDto>
|
||||||
where TDto : class, new()
|
where TDto : class, new()
|
||||||
{
|
{
|
||||||
[Post("/api/dataSaub")]
|
private const string BaseRoute = "/api/dataSaub";
|
||||||
Task<IApiResponse<int>> InsertRangeAsync(IEnumerable<TDto> dtos);
|
|
||||||
|
|
||||||
[Get("/api/dataSaub")]
|
[Post($"{BaseRoute}")]
|
||||||
Task<IApiResponse<IEnumerable<TDto>>> GetAsync(DateTimeOffset dateBegin, DateTimeOffset dateEnd);
|
Task<IApiResponse<int>> InsertRange(IEnumerable<TDto> dtos);
|
||||||
|
|
||||||
|
[Get($"{BaseRoute}")]
|
||||||
|
Task<IApiResponse<IEnumerable<TDto>>> Get(DateTimeOffset dateBegin, DateTimeOffset dateEnd);
|
||||||
|
|
||||||
|
[Get($"{BaseRoute}/resampled")]
|
||||||
|
Task<IApiResponse<IEnumerable<TDto>>> GetResampledData(DateTimeOffset dateBegin, double intervalSec = 600d, int approxPointsCount = 1024);
|
||||||
|
|
||||||
|
[Get($"{BaseRoute}/datesRange")]
|
||||||
|
Task<IApiResponse<DatesRangeDto?>> GetDatesRange();
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,7 @@ using Persistence.Database.Model;
|
|||||||
namespace Persistence.Database.Postgres.Migrations
|
namespace Persistence.Database.Postgres.Migrations
|
||||||
{
|
{
|
||||||
[DbContext(typeof(PersistenceDbContext))]
|
[DbContext(typeof(PersistenceDbContext))]
|
||||||
[Migration("20241118091712_InitialCreate")]
|
[Migration("20241122074646_InitialCreate")]
|
||||||
partial class InitialCreate
|
partial class InitialCreate
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
@ -29,12 +29,9 @@ namespace Persistence.Database.Postgres.Migrations
|
|||||||
|
|
||||||
modelBuilder.Entity("Persistence.Database.Model.DataSaub", b =>
|
modelBuilder.Entity("Persistence.Database.Model.DataSaub", b =>
|
||||||
{
|
{
|
||||||
b.Property<int>("Id")
|
b.Property<DateTimeOffset>("Date")
|
||||||
.ValueGeneratedOnAdd()
|
.HasColumnType("timestamp with time zone")
|
||||||
.HasColumnType("integer")
|
.HasColumnName("date");
|
||||||
.HasColumnName("id");
|
|
||||||
|
|
||||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
|
||||||
|
|
||||||
b.Property<double?>("AxialLoad")
|
b.Property<double?>("AxialLoad")
|
||||||
.HasColumnType("double precision")
|
.HasColumnType("double precision")
|
||||||
@ -52,10 +49,6 @@ namespace Persistence.Database.Postgres.Migrations
|
|||||||
.HasColumnType("double precision")
|
.HasColumnType("double precision")
|
||||||
.HasColumnName("blockSpeed");
|
.HasColumnName("blockSpeed");
|
||||||
|
|
||||||
b.Property<DateTimeOffset>("Date")
|
|
||||||
.HasColumnType("timestamp with time zone")
|
|
||||||
.HasColumnName("date");
|
|
||||||
|
|
||||||
b.Property<double?>("Flow")
|
b.Property<double?>("Flow")
|
||||||
.HasColumnType("double precision")
|
.HasColumnType("double precision")
|
||||||
.HasColumnName("flow");
|
.HasColumnName("flow");
|
||||||
@ -112,7 +105,7 @@ namespace Persistence.Database.Postgres.Migrations
|
|||||||
.HasColumnType("double precision")
|
.HasColumnType("double precision")
|
||||||
.HasColumnName("wellDepth");
|
.HasColumnName("wellDepth");
|
||||||
|
|
||||||
b.HasKey("Id");
|
b.HasKey("Date");
|
||||||
|
|
||||||
b.ToTable("DataSaub");
|
b.ToTable("DataSaub");
|
||||||
});
|
});
|
@ -1,6 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
|
||||||
|
|
||||||
#nullable disable
|
#nullable disable
|
||||||
|
|
||||||
@ -19,8 +18,6 @@ namespace Persistence.Database.Postgres.Migrations
|
|||||||
name: "DataSaub",
|
name: "DataSaub",
|
||||||
columns: table => new
|
columns: table => new
|
||||||
{
|
{
|
||||||
id = table.Column<int>(type: "integer", nullable: false)
|
|
||||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
||||||
date = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
|
date = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
|
||||||
mode = table.Column<int>(type: "integer", nullable: true),
|
mode = table.Column<int>(type: "integer", nullable: true),
|
||||||
user = table.Column<string>(type: "text", nullable: true),
|
user = table.Column<string>(type: "text", nullable: true),
|
||||||
@ -43,7 +40,7 @@ namespace Persistence.Database.Postgres.Migrations
|
|||||||
},
|
},
|
||||||
constraints: table =>
|
constraints: table =>
|
||||||
{
|
{
|
||||||
table.PrimaryKey("PK_DataSaub", x => x.id);
|
table.PrimaryKey("PK_DataSaub", x => x.date);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -26,12 +26,9 @@ namespace Persistence.Database.Postgres.Migrations
|
|||||||
|
|
||||||
modelBuilder.Entity("Persistence.Database.Model.DataSaub", b =>
|
modelBuilder.Entity("Persistence.Database.Model.DataSaub", b =>
|
||||||
{
|
{
|
||||||
b.Property<int>("Id")
|
b.Property<DateTimeOffset>("Date")
|
||||||
.ValueGeneratedOnAdd()
|
.HasColumnType("timestamp with time zone")
|
||||||
.HasColumnType("integer")
|
.HasColumnName("date");
|
||||||
.HasColumnName("id");
|
|
||||||
|
|
||||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
|
||||||
|
|
||||||
b.Property<double?>("AxialLoad")
|
b.Property<double?>("AxialLoad")
|
||||||
.HasColumnType("double precision")
|
.HasColumnType("double precision")
|
||||||
@ -49,10 +46,6 @@ namespace Persistence.Database.Postgres.Migrations
|
|||||||
.HasColumnType("double precision")
|
.HasColumnType("double precision")
|
||||||
.HasColumnName("blockSpeed");
|
.HasColumnName("blockSpeed");
|
||||||
|
|
||||||
b.Property<DateTimeOffset>("Date")
|
|
||||||
.HasColumnType("timestamp with time zone")
|
|
||||||
.HasColumnName("date");
|
|
||||||
|
|
||||||
b.Property<double?>("Flow")
|
b.Property<double?>("Flow")
|
||||||
.HasColumnType("double precision")
|
.HasColumnType("double precision")
|
||||||
.HasColumnName("flow");
|
.HasColumnName("flow");
|
||||||
@ -109,7 +102,7 @@ namespace Persistence.Database.Postgres.Migrations
|
|||||||
.HasColumnType("double precision")
|
.HasColumnType("double precision")
|
||||||
.HasColumnName("wellDepth");
|
.HasColumnName("wellDepth");
|
||||||
|
|
||||||
b.HasKey("Id");
|
b.HasKey("Date");
|
||||||
|
|
||||||
b.ToTable("DataSaub");
|
b.ToTable("DataSaub");
|
||||||
});
|
});
|
||||||
|
@ -1,12 +1,11 @@
|
|||||||
using System.ComponentModel.DataAnnotations.Schema;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
|
||||||
namespace Persistence.Database.Model;
|
namespace Persistence.Database.Model;
|
||||||
public class DataSaub : ITimestampedData
|
public class DataSaub : ITimestampedData
|
||||||
{
|
{
|
||||||
[Column("id")]
|
[Key, Column("date")]
|
||||||
public int Id { get; set; }
|
|
||||||
|
|
||||||
[Column("date")]
|
|
||||||
public DateTimeOffset Date { get; set; }
|
public DateTimeOffset Date { get; set; }
|
||||||
|
|
||||||
[Column("mode")]
|
[Column("mode")]
|
||||||
|
@ -15,7 +15,6 @@ public class DataSaubControllerTest : TimeSeriesBaseControllerTest<DataSaub, Dat
|
|||||||
Date = DateTimeOffset.UtcNow,
|
Date = DateTimeOffset.UtcNow,
|
||||||
Flow = 5,
|
Flow = 5,
|
||||||
HookWeight = 6,
|
HookWeight = 6,
|
||||||
Id = 7,
|
|
||||||
IdFeedRegulator = 8,
|
IdFeedRegulator = 8,
|
||||||
Mode = 9,
|
Mode = 9,
|
||||||
Mse = 10,
|
Mse = 10,
|
||||||
@ -39,7 +38,6 @@ public class DataSaubControllerTest : TimeSeriesBaseControllerTest<DataSaub, Dat
|
|||||||
Date = DateTimeOffset.UtcNow,
|
Date = DateTimeOffset.UtcNow,
|
||||||
Flow = 5,
|
Flow = 5,
|
||||||
HookWeight = 6,
|
HookWeight = 6,
|
||||||
Id = 7,
|
|
||||||
IdFeedRegulator = 8,
|
IdFeedRegulator = 8,
|
||||||
Mode = 9,
|
Mode = 9,
|
||||||
Mse = 10,
|
Mse = 10,
|
||||||
@ -71,4 +69,18 @@ public class DataSaubControllerTest : TimeSeriesBaseControllerTest<DataSaub, Dat
|
|||||||
var endDate = DateTimeOffset.UtcNow;
|
var endDate = DateTimeOffset.UtcNow;
|
||||||
await GetSuccess(beginDate, endDate, entity);
|
await GetSuccess(beginDate, endDate, entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async Task GetDatesRange_returns_success()
|
||||||
|
{
|
||||||
|
await GetDatesRangeSuccess(entity);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async Task GetResampledData_returns_success()
|
||||||
|
{
|
||||||
|
await GetResampledDataSuccess(entity);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -55,7 +55,7 @@ namespace Persistence.IntegrationTests.Controllers
|
|||||||
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
|
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
|
||||||
Assert.NotNull(response.Content);
|
Assert.NotNull(response.Content);
|
||||||
Assert.NotEmpty(response.Content);
|
Assert.NotEmpty(response.Content);
|
||||||
Assert.Equal(response.Content.FirstOrDefault()?.Key, setpointKey);
|
Assert.Equal(setpointKey, response.Content.FirstOrDefault()?.Key);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
@ -93,7 +93,7 @@ namespace Persistence.IntegrationTests.Controllers
|
|||||||
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
|
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
|
||||||
Assert.NotNull(response.Content);
|
Assert.NotNull(response.Content);
|
||||||
Assert.NotEmpty(response.Content);
|
Assert.NotEmpty(response.Content);
|
||||||
Assert.Equal(response.Content.FirstOrDefault()?.Key, setpointKey);
|
Assert.Equal(setpointKey, response.Content.FirstOrDefault()?.Key);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
@ -128,7 +128,7 @@ namespace Persistence.IntegrationTests.Controllers
|
|||||||
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
|
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
|
||||||
Assert.NotNull(response.Content);
|
Assert.NotNull(response.Content);
|
||||||
Assert.NotEmpty(response.Content);
|
Assert.NotEmpty(response.Content);
|
||||||
Assert.Equal(response.Content.FirstOrDefault().Value.FirstOrDefault()?.Key, setpointKey);
|
Assert.Equal(setpointKey, response.Content.FirstOrDefault().Key);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
@ -3,11 +3,12 @@ using Mapster;
|
|||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Persistence.Client;
|
using Persistence.Client;
|
||||||
using Persistence.Client.Clients;
|
using Persistence.Client.Clients;
|
||||||
|
using Persistence.Database.Model;
|
||||||
using Xunit;
|
using Xunit;
|
||||||
|
|
||||||
namespace Persistence.IntegrationTests.Controllers;
|
namespace Persistence.IntegrationTests.Controllers;
|
||||||
public abstract class TimeSeriesBaseControllerTest<TEntity, TDto> : BaseIntegrationTest
|
public abstract class TimeSeriesBaseControllerTest<TEntity, TDto> : BaseIntegrationTest
|
||||||
where TEntity : class
|
where TEntity : class, ITimestampedData, new()
|
||||||
where TDto : class, new()
|
where TDto : class, new()
|
||||||
{
|
{
|
||||||
private ITimeSeriesClient<TDto> timeSeriesClient;
|
private ITimeSeriesClient<TDto> timeSeriesClient;
|
||||||
@ -29,7 +30,7 @@ public abstract class TimeSeriesBaseControllerTest<TEntity, TDto> : BaseIntegrat
|
|||||||
var expected = dto.Adapt<TDto>();
|
var expected = dto.Adapt<TDto>();
|
||||||
|
|
||||||
//act
|
//act
|
||||||
var response = await timeSeriesClient.InsertRangeAsync(new TDto[] { expected });
|
var response = await timeSeriesClient.InsertRange(new TDto[] { expected });
|
||||||
|
|
||||||
//assert
|
//assert
|
||||||
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
|
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
|
||||||
@ -45,11 +46,80 @@ public abstract class TimeSeriesBaseControllerTest<TEntity, TDto> : BaseIntegrat
|
|||||||
|
|
||||||
dbContext.SaveChanges();
|
dbContext.SaveChanges();
|
||||||
|
|
||||||
var response = await timeSeriesClient.GetAsync(beginDate, endDate);
|
var response = await timeSeriesClient.Get(beginDate, endDate);
|
||||||
|
|
||||||
//assert
|
//assert
|
||||||
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
|
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
|
||||||
Assert.NotNull(response.Content);
|
Assert.NotNull(response.Content);
|
||||||
Assert.Single(response.Content);
|
Assert.Single(response.Content);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task GetDatesRangeSuccess(TEntity entity)
|
||||||
|
{
|
||||||
|
//arrange
|
||||||
|
var datesRangeExpected = 30;
|
||||||
|
|
||||||
|
var entity2 = entity.Adapt<TEntity>();
|
||||||
|
entity2.Date = entity.Date.AddDays(datesRangeExpected);
|
||||||
|
|
||||||
|
var dbset = dbContext.Set<TEntity>();
|
||||||
|
dbset.Add(entity);
|
||||||
|
dbset.Add(entity2);
|
||||||
|
|
||||||
|
dbContext.SaveChanges();
|
||||||
|
|
||||||
|
var response = await timeSeriesClient.GetDatesRange();
|
||||||
|
|
||||||
|
//assert
|
||||||
|
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
|
||||||
|
Assert.NotNull(response.Content);
|
||||||
|
|
||||||
|
var datesRangeActual = (response.Content.To - response.Content.From).Days;
|
||||||
|
Assert.Equal(datesRangeExpected, datesRangeActual);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task GetResampledDataSuccess(TEntity entity)
|
||||||
|
{
|
||||||
|
//arrange
|
||||||
|
var approxPointsCount = 10;
|
||||||
|
var differenceBetweenStartAndEndDays = 50;
|
||||||
|
|
||||||
|
var entities = new List<TEntity>();
|
||||||
|
for (var i = 1; i <= differenceBetweenStartAndEndDays; i++)
|
||||||
|
{
|
||||||
|
var entity2 = entity.Adapt<TEntity>();
|
||||||
|
entity2.Date = entity.Date.AddDays(i - 1);
|
||||||
|
|
||||||
|
entities.Add(entity2);
|
||||||
|
}
|
||||||
|
|
||||||
|
var dbset = dbContext.Set<TEntity>();
|
||||||
|
dbset.AddRange(entities);
|
||||||
|
|
||||||
|
dbContext.SaveChanges();
|
||||||
|
|
||||||
|
var response = await timeSeriesClient.GetResampledData(entity.Date.AddMinutes(-1), differenceBetweenStartAndEndDays * 24 * 60 * 60 + 60, approxPointsCount);
|
||||||
|
|
||||||
|
//assert
|
||||||
|
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
|
||||||
|
Assert.NotNull(response.Content);
|
||||||
|
|
||||||
|
var ratio = entities.Count() / approxPointsCount;
|
||||||
|
if (ratio > 1)
|
||||||
|
{
|
||||||
|
var expectedResampledCount = entities
|
||||||
|
.Where((_, index) => index % ratio == 0)
|
||||||
|
.Count();
|
||||||
|
|
||||||
|
Assert.Equal(expectedResampledCount, response.Content.Count());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Assert.Equal(entities.Count(), response.Content.Count());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -4,8 +4,6 @@ using System.ComponentModel.DataAnnotations.Schema;
|
|||||||
namespace Persistence.Repository.Data;
|
namespace Persistence.Repository.Data;
|
||||||
public class DataSaubDto : ITimeSeriesAbstractDto
|
public class DataSaubDto : ITimeSeriesAbstractDto
|
||||||
{
|
{
|
||||||
public int Id { get; set; }
|
|
||||||
|
|
||||||
public DateTimeOffset Date { get; set; } = DateTimeOffset.UtcNow;
|
public DateTimeOffset Date { get; set; } = DateTimeOffset.UtcNow;
|
||||||
|
|
||||||
public int? Mode { get; set; }
|
public int? Mode { get; set; }
|
||||||
|
@ -35,6 +35,7 @@ namespace Persistence.Repository.Repositories
|
|||||||
.ToArrayAsync(token);
|
.ToArrayAsync(token);
|
||||||
var filteredEntities = entities
|
var filteredEntities = entities
|
||||||
.GroupBy(e => e.Key)
|
.GroupBy(e => e.Key)
|
||||||
|
.Select(e => e.OrderBy(o => o.Created))
|
||||||
.Select(e => e.Where(e => e.Created <= historyMoment).Last());
|
.Select(e => e.Where(e => e.Created <= historyMoment).Last());
|
||||||
var dtos = filteredEntities
|
var dtos = filteredEntities
|
||||||
.Select(e => e.Adapt<SetpointValueDto>());
|
.Select(e => e.Adapt<SetpointValueDto>());
|
||||||
|
@ -10,8 +10,8 @@ public class TimeSeriesDataCachedRepository<TEntity, TDto> : TimeSeriesDataRepos
|
|||||||
where TEntity : class, ITimestampedData, new()
|
where TEntity : class, ITimestampedData, new()
|
||||||
where TDto : class, ITimeSeriesAbstractDto, new()
|
where TDto : class, ITimeSeriesAbstractDto, new()
|
||||||
{
|
{
|
||||||
public static TDto FirstByDate { get; set; } = default!;
|
public static TDto? FirstByDate { get; private set; }
|
||||||
public static CyclicArray<TDto> LastData { get; set; } = null!;
|
public static CyclicArray<TDto> LastData { get; } = new CyclicArray<TDto>(CacheItemsCount);
|
||||||
|
|
||||||
private const int CacheItemsCount = 3600;
|
private const int CacheItemsCount = 3600;
|
||||||
|
|
||||||
@ -19,8 +19,6 @@ public class TimeSeriesDataCachedRepository<TEntity, TDto> : TimeSeriesDataRepos
|
|||||||
{
|
{
|
||||||
Task.Run(async () =>
|
Task.Run(async () =>
|
||||||
{
|
{
|
||||||
LastData = new CyclicArray<TDto>(CacheItemsCount);
|
|
||||||
|
|
||||||
var firstDateItem = await base.GetFirstAsync(CancellationToken.None);
|
var firstDateItem = await base.GetFirstAsync(CancellationToken.None);
|
||||||
if (firstDateItem == null)
|
if (firstDateItem == null)
|
||||||
{
|
{
|
||||||
@ -35,17 +33,17 @@ public class TimeSeriesDataCachedRepository<TEntity, TDto> : TimeSeriesDataRepos
|
|||||||
}).Wait();
|
}).Wait();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override async Task<IEnumerable<TDto>> GetAsync(DateTimeOffset dateBegin, DateTimeOffset dateEnd, CancellationToken token)
|
public override async Task<IEnumerable<TDto>> GetGtDate(DateTimeOffset dateBegin, CancellationToken token)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (LastData.Count() == 0 || LastData[0].Date > dateBegin)
|
if (LastData.Count() == 0 || LastData[0].Date > dateBegin)
|
||||||
{
|
{
|
||||||
var dtos = await base.GetAsync(dateBegin, dateEnd, token);
|
var dtos = await base.GetGtDate(dateBegin, token);
|
||||||
return dtos;
|
return dtos;
|
||||||
}
|
}
|
||||||
|
|
||||||
var items = LastData
|
var items = LastData
|
||||||
.Where(i => i.Date >= dateBegin && i.Date <= dateEnd);
|
.Where(i => i.Date >= dateBegin);
|
||||||
|
|
||||||
return items;
|
return items;
|
||||||
}
|
}
|
||||||
@ -64,5 +62,44 @@ public class TimeSeriesDataCachedRepository<TEntity, TDto> : TimeSeriesDataRepos
|
|||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override async Task<DatesRangeDto?> GetDatesRange(CancellationToken token)
|
||||||
|
{
|
||||||
|
if (FirstByDate == null)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
return await Task.Run(() =>
|
||||||
|
{
|
||||||
|
return new DatesRangeDto
|
||||||
|
{
|
||||||
|
From = FirstByDate.Date,
|
||||||
|
To = LastData[^1].Date
|
||||||
|
};
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public override async Task<IEnumerable<TDto>> GetResampledData(
|
||||||
|
DateTimeOffset dateBegin,
|
||||||
|
double intervalSec = 600d,
|
||||||
|
int approxPointsCount = 1024,
|
||||||
|
CancellationToken token = default)
|
||||||
|
{
|
||||||
|
var dtos = LastData.Where(i => i.Date >= dateBegin);
|
||||||
|
if (LastData.Count == 0 || LastData[0].Date > dateBegin)
|
||||||
|
{
|
||||||
|
dtos = await base.GetGtDate(dateBegin, token);
|
||||||
|
}
|
||||||
|
|
||||||
|
var dateEnd = dateBegin.AddSeconds(intervalSec);
|
||||||
|
dtos = dtos
|
||||||
|
.Where(i => i.Date <= dateEnd);
|
||||||
|
|
||||||
|
var ratio = dtos.Count() / approxPointsCount;
|
||||||
|
if (ratio > 1)
|
||||||
|
dtos = dtos
|
||||||
|
.Where((_, index) => index % ratio == 0);
|
||||||
|
|
||||||
|
return dtos;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,16 +18,7 @@ public class TimeSeriesDataRepository<TEntity, TDto> : ITimeSeriesDataRepository
|
|||||||
|
|
||||||
protected virtual IQueryable<TEntity> GetQueryReadOnly() => this.db.Set<TEntity>();
|
protected virtual IQueryable<TEntity> GetQueryReadOnly() => this.db.Set<TEntity>();
|
||||||
|
|
||||||
public virtual async Task<IEnumerable<TDto>> GetAsync(DateTimeOffset dateBegin, DateTimeOffset dateEnd, CancellationToken token)
|
public virtual async Task<DatesRangeDto?> GetDatesRange(CancellationToken token)
|
||||||
{
|
|
||||||
var query = GetQueryReadOnly();
|
|
||||||
var entities = await query.ToArrayAsync(token);
|
|
||||||
var dtos = entities.Select(e => e.Adapt<TDto>());
|
|
||||||
|
|
||||||
return dtos;
|
|
||||||
}
|
|
||||||
|
|
||||||
public virtual async Task<DatesRangeDto> GetDatesRangeAsync(CancellationToken token)
|
|
||||||
{
|
{
|
||||||
var query = GetQueryReadOnly();
|
var query = GetQueryReadOnly();
|
||||||
var minDate = await query.MinAsync(o => o.Date, token);
|
var minDate = await query.MinAsync(o => o.Date, token);
|
||||||
@ -60,7 +51,7 @@ public class TimeSeriesDataRepository<TEntity, TDto> : ITimeSeriesDataRepository
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<IEnumerable<TDto>> GetLastAsync(int takeCount, CancellationToken token)
|
protected async Task<IEnumerable<TDto>> GetLastAsync(int takeCount, CancellationToken token)
|
||||||
{
|
{
|
||||||
var query = GetQueryReadOnly()
|
var query = GetQueryReadOnly()
|
||||||
.OrderByDescending(e => e.Date)
|
.OrderByDescending(e => e.Date)
|
||||||
@ -72,7 +63,7 @@ public class TimeSeriesDataRepository<TEntity, TDto> : ITimeSeriesDataRepository
|
|||||||
return dtos;
|
return dtos;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<TDto?> GetFirstAsync(CancellationToken token)
|
protected async Task<TDto?> GetFirstAsync(CancellationToken token)
|
||||||
{
|
{
|
||||||
var query = GetQueryReadOnly()
|
var query = GetQueryReadOnly()
|
||||||
.OrderBy(e => e.Date);
|
.OrderBy(e => e.Date);
|
||||||
@ -85,4 +76,24 @@ public class TimeSeriesDataRepository<TEntity, TDto> : ITimeSeriesDataRepository
|
|||||||
var dto = entity.Adapt<TDto>();
|
var dto = entity.Adapt<TDto>();
|
||||||
return dto;
|
return dto;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async virtual Task<IEnumerable<TDto>> GetResampledData(
|
||||||
|
DateTimeOffset dateBegin,
|
||||||
|
double intervalSec = 600d,
|
||||||
|
int approxPointsCount = 1024,
|
||||||
|
CancellationToken token = default)
|
||||||
|
{
|
||||||
|
var dtos = await GetGtDate(dateBegin, token);
|
||||||
|
|
||||||
|
var dateEnd = dateBegin.AddSeconds(intervalSec);
|
||||||
|
dtos = dtos
|
||||||
|
.Where(i => i.Date <= dateEnd);
|
||||||
|
|
||||||
|
var ratio = dtos.Count() / approxPointsCount;
|
||||||
|
if (ratio > 1)
|
||||||
|
dtos = dtos
|
||||||
|
.Where((_, index) => index % ratio == 0);
|
||||||
|
|
||||||
|
return dtos;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,7 @@ public interface IChangeLogApi<TDto, TChangeLogDto>
|
|||||||
/// <param name="dto"></param>
|
/// <param name="dto"></param>
|
||||||
/// <param name="token"></param>
|
/// <param name="token"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<ActionResult<int>> AddAsync(TDto dto, CancellationToken token);
|
Task<ActionResult<int>> Add(TDto dto, CancellationToken token);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Добавить несколько записей
|
/// Добавить несколько записей
|
||||||
@ -39,7 +39,7 @@ public interface IChangeLogApi<TDto, TChangeLogDto>
|
|||||||
/// <param name="dtos"></param>
|
/// <param name="dtos"></param>
|
||||||
/// <param name="token"></param>
|
/// <param name="token"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<ActionResult<int>> AddRangeAsync(IEnumerable<TDto> dtos, CancellationToken token);
|
Task<ActionResult<int>> AddRange(IEnumerable<TDto> dtos, CancellationToken token);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Обновить одну запись
|
/// Обновить одну запись
|
||||||
@ -47,7 +47,7 @@ public interface IChangeLogApi<TDto, TChangeLogDto>
|
|||||||
/// <param name="dto"></param>
|
/// <param name="dto"></param>
|
||||||
/// <param name="token"></param>
|
/// <param name="token"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<ActionResult<int>> UpdateAsync(TDto dto, CancellationToken token);
|
Task<ActionResult<int>> Update(TDto dto, CancellationToken token);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Обновить несколько записей
|
/// Обновить несколько записей
|
||||||
@ -55,7 +55,7 @@ public interface IChangeLogApi<TDto, TChangeLogDto>
|
|||||||
/// <param name="dtos"></param>
|
/// <param name="dtos"></param>
|
||||||
/// <param name="token"></param>
|
/// <param name="token"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<ActionResult<int>> UpdateRangeAsync(IEnumerable<TDto> dtos, CancellationToken token);
|
Task<ActionResult<int>> UpdateRange(IEnumerable<TDto> dtos, CancellationToken token);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Удалить одну запись
|
/// Удалить одну запись
|
||||||
@ -63,7 +63,7 @@ public interface IChangeLogApi<TDto, TChangeLogDto>
|
|||||||
/// <param name="id"></param>
|
/// <param name="id"></param>
|
||||||
/// <param name="token"></param>
|
/// <param name="token"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<ActionResult<int>> DeleteAsync(int id, CancellationToken token);
|
Task<ActionResult<int>> Delete(int id, CancellationToken token);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Удалить несколько записей
|
/// Удалить несколько записей
|
||||||
@ -71,5 +71,5 @@ public interface IChangeLogApi<TDto, TChangeLogDto>
|
|||||||
/// <param name="ids"></param>
|
/// <param name="ids"></param>
|
||||||
/// <param name="token"></param>
|
/// <param name="token"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<ActionResult<int>> DeleteRangeAsync(IEnumerable<int> ids, CancellationToken token);
|
Task<ActionResult<int>> DeleteRange(IEnumerable<int> ids, CancellationToken token);
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,7 @@ public interface IDictionaryElementApi<TDto> where TDto : class, new()
|
|||||||
/// <param name="dictionaryKey">ключ справочника</param>
|
/// <param name="dictionaryKey">ключ справочника</param>
|
||||||
/// <param name="token"></param>
|
/// <param name="token"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<ActionResult<IEnumerable<TDto>>> GetAsync(Guid dictionaryKey, CancellationToken token);
|
Task<ActionResult<IEnumerable<TDto>>> Get(Guid dictionaryKey, CancellationToken token);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Добавить элемент в справочник
|
/// Добавить элемент в справочник
|
||||||
@ -22,7 +22,7 @@ public interface IDictionaryElementApi<TDto> where TDto : class, new()
|
|||||||
/// <param name="dto"></param>
|
/// <param name="dto"></param>
|
||||||
/// <param name="token"></param>
|
/// <param name="token"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<ActionResult<Guid>> AddAsync(Guid dictionaryKey, TDto dto, CancellationToken token);
|
Task<ActionResult<Guid>> Add(Guid dictionaryKey, TDto dto, CancellationToken token);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Изменить одну запись
|
/// Изменить одну запись
|
||||||
@ -32,7 +32,7 @@ public interface IDictionaryElementApi<TDto> where TDto : class, new()
|
|||||||
/// <param name="dto"></param>
|
/// <param name="dto"></param>
|
||||||
/// <param name="token"></param>
|
/// <param name="token"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<ActionResult<Guid>> UpdateAsync(Guid dictionaryKey, Guid dictionaryElementKey, TDto dto, CancellationToken token);
|
Task<ActionResult<Guid>> Update(Guid dictionaryKey, Guid dictionaryElementKey, TDto dto, CancellationToken token);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Удалить одну запись
|
/// Удалить одну запись
|
||||||
@ -41,5 +41,5 @@ public interface IDictionaryElementApi<TDto> where TDto : class, new()
|
|||||||
/// <param name="dictionaryElementKey">ключ элемента в справочнике</param>
|
/// <param name="dictionaryElementKey">ключ элемента в справочнике</param>
|
||||||
/// <param name="token"></param>
|
/// <param name="token"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<ActionResult<int>> DeleteAsync(Guid dictionaryKey, Guid dictionaryElementKey, CancellationToken token);
|
Task<ActionResult<int>> Delete(Guid dictionaryKey, Guid dictionaryElementKey, CancellationToken token);
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@ public interface ISyncApi<TDto> where TDto : class, new()
|
|||||||
/// <param name="take">количество записей</param>
|
/// <param name="take">количество записей</param>
|
||||||
/// <param name="token"></param>
|
/// <param name="token"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<ActionResult<IEnumerable<TDto>>> GetPartAsync(DateTimeOffset dateBegin, int take = 24 * 60 * 60, CancellationToken token = default);
|
Task<ActionResult<IEnumerable<TDto>>> GetPart(DateTimeOffset dateBegin, int take = 24 * 60 * 60, CancellationToken token = default);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Получить диапазон дат, для которых есть данные в репозитории
|
/// Получить диапазон дат, для которых есть данные в репозитории
|
||||||
|
@ -19,5 +19,5 @@ public interface ITableDataApi<TDto, TRequest>
|
|||||||
/// <param name="request">параметры фильтрации</param>
|
/// <param name="request">параметры фильтрации</param>
|
||||||
/// <param name="token"></param>
|
/// <param name="token"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<ActionResult<PaginationContainer<TDto>>> GetPageAsync(TRequest request, CancellationToken token);
|
Task<ActionResult<PaginationContainer<TDto>>> GetPage(TRequest request, CancellationToken token);
|
||||||
}
|
}
|
||||||
|
@ -4,23 +4,27 @@ using Persistence.Models;
|
|||||||
namespace Persistence.API;
|
namespace Persistence.API;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Интерфейс для работы с API графиков
|
/// Базовый интерфейс для работы с временными рядами
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public interface IGraphDataApi<TDto>
|
public interface ITimeSeriesBaseDataApi<TDto>
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Получить список объектов с прореживанием, удовлетворящий диапазону дат
|
/// Получить список объектов с прореживанием, удовлетворяющий диапазону дат
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="dateBegin">дата начала</param>
|
/// <param name="dateBegin">дата начала</param>
|
||||||
/// <param name="dateEnd">дата окончания</param>
|
/// <param name="dateEnd">дата окончания</param>
|
||||||
/// <param name="approxPointsCount"></param>
|
/// <param name="approxPointsCount"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<ActionResult<IEnumerable<TDto>>> GetThinnedDataAsync(DateTimeOffset dateBegin, DateTimeOffset dateEnd, int approxPointsCount = 1024);
|
Task<IActionResult> GetResampledData(
|
||||||
|
DateTimeOffset dateBegin,
|
||||||
|
double intervalSec = 600d,
|
||||||
|
int approxPointsCount = 1024,
|
||||||
|
CancellationToken token = default);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Получить диапазон дат, для которых есть данные в репозитории
|
/// Получить диапазон дат, для которых есть данные в репозитории
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="token"></param>
|
/// <param name="token"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<ActionResult<DatesRangeDto>> GetDatesRangeAsync(CancellationToken token);
|
Task<IActionResult> GetDatesRange(CancellationToken token);
|
||||||
}
|
}
|
@ -11,24 +11,16 @@ namespace Persistence.API;
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Интерфейс для работы с API временных данных
|
/// Интерфейс для работы с API временных данных
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public interface ITimeSeriesDataApi<TDto>
|
public interface ITimeSeriesDataApi<TDto> : ITimeSeriesBaseDataApi<TDto>
|
||||||
where TDto : class, ITimeSeriesAbstractDto, new()
|
where TDto : class, ITimeSeriesAbstractDto, new()
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Получить список объектов, удовлетворяющий диапазон дат
|
/// Получить список объектов, удовлетворяющий диапазон дат
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="dateBegin">дата начала</param>
|
/// <param name="dateBegin">дата начала</param>
|
||||||
/// <param name="dateEnd">дата окончания</param>
|
|
||||||
/// <param name="token"></param>
|
/// <param name="token"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<IActionResult> GetAsync(DateTimeOffset dateBegin, DateTimeOffset dateEnd, CancellationToken token);
|
Task<IActionResult> Get(DateTimeOffset dateBegin, CancellationToken token);
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Получить диапазон дат, для которых есть данные в репозитории
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="token"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
Task<IActionResult> GetDatesRangeAsync(CancellationToken token);
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Добавление записей
|
/// Добавление записей
|
||||||
@ -36,7 +28,7 @@ public interface ITimeSeriesDataApi<TDto>
|
|||||||
/// <param name="dtos"></param>
|
/// <param name="dtos"></param>
|
||||||
/// <param name="token"></param>
|
/// <param name="token"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<IActionResult> InsertRangeAsync(IEnumerable<TDto> dtos, CancellationToken token);
|
Task<IActionResult> InsertRange(IEnumerable<TDto> dtos, CancellationToken token);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,7 @@ public class ChangeLogDto<T> where T: class
|
|||||||
public DateTimeOffset Creation { get; set; }
|
public DateTimeOffset Creation { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Дата устаревания (например при удалении)
|
/// Дата устаревания (например, при удалении)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public DateTimeOffset? Obsolete { get; set; }
|
public DateTimeOffset? Obsolete { get; set; }
|
||||||
|
|
||||||
|
@ -15,5 +15,5 @@ public interface ITableDataRepository<TDto, TRequest>
|
|||||||
/// <param name="request">параметры фильтрации</param>
|
/// <param name="request">параметры фильтрации</param>
|
||||||
/// <param name="token"></param>
|
/// <param name="token"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<IEnumerable<TDto>> GetAsync(TRequest request, CancellationToken token);
|
Task<IEnumerable<TDto>> Get(TRequest request, CancellationToken token);
|
||||||
}
|
}
|
||||||
|
@ -5,22 +5,25 @@ namespace Persistence.Repositories;
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Интерфейс по работе с прореженными данными
|
/// Интерфейс по работе с прореженными данными
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public interface IGraphDataRepository<TDto>
|
public interface ITimeSeriesBaseRepository<TDto>
|
||||||
where TDto : class, new()
|
where TDto : class, new()
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Получить список объектов с прореживанием
|
/// Получить список объектов с прореживанием
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="dateBegin">дата начала</param>
|
/// <param name="dateBegin">дата начала</param>
|
||||||
/// <param name="dateEnd">дата окончания</param>
|
|
||||||
/// <param name="approxPointsCount"></param>
|
/// <param name="approxPointsCount"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<IEnumerable<TDto>> GetThinnedDataAsync(DateTimeOffset dateBegin, DateTimeOffset dateEnd, int approxPointsCount = 1024);
|
Task<IEnumerable<TDto>> GetResampledData(
|
||||||
|
DateTimeOffset dateBegin,
|
||||||
|
double intervalSec = 600d,
|
||||||
|
int approxPointsCount = 1024,
|
||||||
|
CancellationToken token = default);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Получить диапазон дат, для которых есть данные в репозитории
|
/// Получить диапазон дат, для которых есть данные в репозитории
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="token"></param>
|
/// <param name="token"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<DatesRangeDto> GetDatesRangeAsync(CancellationToken token);
|
Task<DatesRangeDto?> GetDatesRange(CancellationToken token);
|
||||||
}
|
}
|
@ -6,24 +6,9 @@ namespace Persistence.Repositories;
|
|||||||
/// Интерфейс по работе с временными данными
|
/// Интерфейс по работе с временными данными
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <typeparam name="TDto"></typeparam>
|
/// <typeparam name="TDto"></typeparam>
|
||||||
public interface ITimeSeriesDataRepository<TDto> : ISyncRepository<TDto>
|
public interface ITimeSeriesDataRepository<TDto> : ISyncRepository<TDto>, ITimeSeriesBaseRepository<TDto>
|
||||||
where TDto : class, ITimeSeriesAbstractDto, new()
|
where TDto : class, ITimeSeriesAbstractDto, new()
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// Получить страницу списка объектов
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="dateBegin">дата начала</param>
|
|
||||||
/// <param name="dateEnd">дата окончания</param>
|
|
||||||
/// <param name="token"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
Task<IEnumerable<TDto>> GetAsync(DateTimeOffset dateBegin, DateTimeOffset dateEnd, CancellationToken token);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Получить диапазон дат, для которых есть данные в репозитории
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="token"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
Task<DatesRangeDto> GetDatesRangeAsync(CancellationToken token);
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Добавление записей
|
/// Добавление записей
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -31,19 +16,4 @@ public interface ITimeSeriesDataRepository<TDto> : ISyncRepository<TDto>
|
|||||||
/// <param name="token"></param>
|
/// <param name="token"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<int> InsertRange(IEnumerable<TDto> dtos, CancellationToken token);
|
Task<int> InsertRange(IEnumerable<TDto> dtos, CancellationToken token);
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Получение списка последних записей
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="takeCount">количество записей</param>
|
|
||||||
/// <param name="token"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
Task<IEnumerable<TDto>> GetLastAsync(int takeCount, CancellationToken token);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Получение первой записи
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="token"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
Task<TDto?> GetFirstAsync(CancellationToken token);
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user