mirror of
https://github.com/Cleanuparr/Cleanuparr.git
synced 2026-06-10 23:06:04 -04:00
added config db
This commit is contained in:
@@ -12,9 +12,9 @@ namespace Executable.Controllers;
|
||||
[Route("api/[controller]")]
|
||||
public class EventsController : ControllerBase
|
||||
{
|
||||
private readonly DataContext _context;
|
||||
private readonly EventsContext _context;
|
||||
|
||||
public EventsController(DataContext context)
|
||||
public EventsController(EventsContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
@@ -66,7 +66,7 @@ public class EventsController : ControllerBase
|
||||
// Apply search filter if provided
|
||||
if (!string.IsNullOrWhiteSpace(search))
|
||||
{
|
||||
string pattern = DataContext.GetLikePattern(search);
|
||||
string pattern = EventsContext.GetLikePattern(search);
|
||||
query = query.Where(e =>
|
||||
EF.Functions.Like(e.Message, pattern) ||
|
||||
EF.Functions.Like(e.Data, pattern) ||
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
using Common.Helpers;
|
||||
using Common.Helpers;
|
||||
using Data.Enums;
|
||||
using Infrastructure.Configuration;
|
||||
using Infrastructure.Verticals.ContentBlocker;
|
||||
using Infrastructure.Verticals.DownloadCleaner;
|
||||
using Infrastructure.Verticals.QueueCleaner;
|
||||
using Serilog;
|
||||
|
||||
@@ -25,7 +25,7 @@ public static class ServicesDI
|
||||
services
|
||||
.AddSingleton<IEncryptionService, AesEncryptionService>()
|
||||
.AddTransient<SensitiveDataJsonConverter>()
|
||||
.AddTransient<DataContext>()
|
||||
.AddTransient<EventsContext>()
|
||||
.AddTransient<EventPublisher>()
|
||||
.AddHostedService<EventCleanupService>()
|
||||
// API services
|
||||
|
||||
@@ -34,10 +34,16 @@ public static class HostExtensions
|
||||
}
|
||||
|
||||
// Apply db migrations
|
||||
var dbContext = host.Services.GetRequiredService<DataContext>();
|
||||
if ((await dbContext.Database.GetPendingMigrationsAsync()).Any())
|
||||
var eventsContext = host.Services.GetRequiredService<EventsContext>();
|
||||
if ((await eventsContext.Database.GetPendingMigrationsAsync()).Any())
|
||||
{
|
||||
await dbContext.Database.MigrateAsync();
|
||||
await eventsContext.Database.MigrateAsync();
|
||||
}
|
||||
|
||||
var configContext = host.Services.GetRequiredService<DataContext>();
|
||||
if ((await configContext.Database.GetPendingMigrationsAsync()).Any())
|
||||
{
|
||||
await configContext.Database.MigrateAsync();
|
||||
}
|
||||
|
||||
return host;
|
||||
|
||||
Reference in New Issue
Block a user