feat(assets): dynamic settings, IFinlyticLogger, live log streaming, and EF migration
This commit is contained in:
+15
-10
@@ -1,19 +1,27 @@
|
||||
using System.Text.Json;
|
||||
using FinlyticAssets;
|
||||
using System;
|
||||
using FinlyticAssets.Database;
|
||||
using FinlyticCore.Services.TradeRepublic;
|
||||
using FinlyticAssets.Util;
|
||||
using FinlyticAssets.Services;
|
||||
using FinlyticAssets.Util;
|
||||
using FinlyticCore.Database;
|
||||
using FinlyticCore.Services;
|
||||
using FinlyticCore.Services.TradeRepublic;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
|
||||
var builder = Host.CreateApplicationBuilder(args);
|
||||
|
||||
// DB Context
|
||||
builder.Services.AddDbContext<AssetsDbContext>(options =>
|
||||
options.UseNpgsql(builder.Configuration.GetConnectionString("DefaultConnection")));
|
||||
builder.Services.AddScoped<ISettingsDbContext>(sp => sp.GetRequiredService<AssetsDbContext>());
|
||||
|
||||
// Core Services
|
||||
builder.Services.AddSingleton<ISettingsService, SettingsService>();
|
||||
builder.Services.AddSingleton(typeof(IFinlyticLogger<>), typeof(FinlyticLogger<>));
|
||||
|
||||
builder.Services.AddScoped<TradeRepublicClient>();
|
||||
|
||||
builder.Services.AddScoped<ITradeRepublicService, TradeRepublicService>();
|
||||
builder.Services.AddScoped<IAssetsDbService, AssetsDbService>();
|
||||
builder.Services.AddScoped<ISettingsDbService, SettingsDbService>();
|
||||
@@ -34,8 +42,6 @@ using (var scope = host.Services.CreateScope())
|
||||
var context = scope.ServiceProvider.GetRequiredService<AssetsDbContext>();
|
||||
await context.Database.MigrateAsync();
|
||||
|
||||
// Fix: Reset InitAssetUpdateTypeDelay from old default (3600s) to new default (0s = no delay).
|
||||
// This ensures the scanner moves immediately to the next asset type during the initial scan.
|
||||
var settingsService = scope.ServiceProvider.GetRequiredService<ISettingsDbService>();
|
||||
var settings = await settingsService.GetSettings();
|
||||
if (settings.InitAssetUpdateTypeDelay == 3600)
|
||||
@@ -47,8 +53,7 @@ using (var scope = host.Services.CreateScope())
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine($"Critical error during database migration: {ex.Message}");
|
||||
Console.WriteLine(ex.StackTrace);
|
||||
Console.WriteLine($"Critical error during database migration for FinlyticAssets: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user