Мелкие правки: удаление комментариев, переименование файлов и т.д.

This commit is contained in:
Оля Бизюкова 2025-01-28 12:30:58 +05:00
parent afd1e733f5
commit c2de8a0cc2
3 changed files with 7 additions and 13 deletions

View File

@ -6,7 +6,7 @@
} }
}, },
"ConnectionStrings": { "ConnectionStrings": {
"DefaultConnection": "Host=localhost:5462;Database=persistence;Username=postgres;Password=postgres;Persist Security Info=True" "DefaultConnection": "Host=localhost;Database=persistence;Username=postgres;Password=postgres;Persist Security Info=True"
}, },
"AllowedHosts": "*", "AllowedHosts": "*",
"NeedUseKeyCloak": false, "NeedUseKeyCloak": false,

View File

@ -5,19 +5,19 @@ using Npgsql;
namespace DD.Persistence.Database.Postgres.Test; namespace DD.Persistence.Database.Postgres.Test;
public class UnitTest1 : IClassFixture<DbFixture> public class UnitTestCheckHyperTables : IClassFixture<DbFixture>
{ {
private ServiceProvider _serviceProvider; private ServiceProvider _serviceProvider;
private string _connectionString; private string _connectionString;
public UnitTest1(DbFixture fixture) public UnitTestCheckHyperTables(DbFixture fixture)
{ {
_serviceProvider = fixture.serviceProvider; _serviceProvider = fixture.serviceProvider;
_connectionString = fixture.connectionString; _connectionString = fixture.connectionString;
} }
[Fact] [Fact]
public void CreateHyperTable() public void CreateHyperTable_For_ParameterData_Return_Success()
{ {
var entity = new ParameterData() var entity = new ParameterData()
{ {

View File

@ -25,6 +25,7 @@ public static class EFExtensionsPartitioning
/// <param name="db"></param> /// <param name="db"></param>
private static void AddParameterDataPartitioning(this DatabaseFacade db) private static void AddParameterDataPartitioning(this DatabaseFacade db)
{ {
var dayCount = 1;
var type = typeof(ParameterData); var type = typeof(ParameterData);
var tableAttribute = type.GetCustomAttribute<TableAttribute>(); var tableAttribute = type.GetCustomAttribute<TableAttribute>();
if (tableAttribute is null) if (tableAttribute is null)
@ -33,17 +34,10 @@ public static class EFExtensionsPartitioning
} }
var sqlCreateHypertableString = $"SELECT create_hypertable('{tableAttribute.Name}'," + var sqlCreateHypertableString = $"SELECT create_hypertable('{tableAttribute.Name}'," +
$"by_range('{nameof(ParameterData.Timestamp)}', INTERVAL '1 day'), if_not_exists => {true});"; $"by_range('{nameof(ParameterData.Timestamp)}', INTERVAL '{dayCount} day'), if_not_exists => {true});";
db.ExecuteSqlRaw(sqlCreateHypertableString); db.ExecuteSqlRaw(sqlCreateHypertableString);
var sqlCreateDimensionString = $"SELECT add_dimension('{tableAttribute.Name}'," + var sqlCreateDimensionString = $"SELECT add_dimension('{tableAttribute.Name}'," +
$"by_hash('{nameof(ParameterData.ParameterId)}', 1));"; $"by_hash('{nameof(ParameterData.ParameterId)}', {dayCount}));";
db.ExecuteSqlRaw(sqlCreateDimensionString);
//var sqlString = $"SELECT create_hypertable('{tableAttribute.Name}'," +
// $"'{nameof(ParameterData.Timestamp)}'," +
// $"'{nameof(ParameterData.ParameterId)}'," +
// $"{sectionsNumber}," +
// $"chunk_time_interval => INTERVAL '{chunkTimeInterval} day');";
//db.ExecuteSqlRaw(sqlString);
} }
} }