feat: exorcise entity framework core from most responders

This commit is contained in:
sam 2024-10-27 23:02:42 +01:00
parent 33b78a7ac5
commit 5891f28f7c
Signed by: sam
GPG key ID: 5F3C3C1B3166639D
32 changed files with 743 additions and 145 deletions

View file

@ -22,6 +22,8 @@ using Catalogger.Backend.Cache;
using Catalogger.Backend.Cache.InMemoryCache;
using Catalogger.Backend.Cache.RedisCache;
using Catalogger.Backend.Database;
using Catalogger.Backend.Database.Dapper;
using Catalogger.Backend.Database.Dapper.Repositories;
using Catalogger.Backend.Database.Queries;
using Catalogger.Backend.Database.Redis;
using Catalogger.Backend.Services;
@ -103,6 +105,9 @@ public static class StartupExtensions
public static IServiceCollection AddCustomServices(this IServiceCollection services) =>
services
.AddSingleton<IClock>(SystemClock.Instance)
.AddDatabasePool()
.AddScoped<DapperMessageRepository>()
.AddScoped<GuildRepository>()
.AddSingleton<GuildCache>()
.AddSingleton<RoleCache>()
.AddSingleton<ChannelCache>()
@ -113,7 +118,7 @@ public static class StartupExtensions
.AddSingleton<NewsService>()
.AddScoped<IEncryptionService, EncryptionService>()
.AddSingleton<MetricsCollectionService>()
.AddScoped<MessageRepository>()
// .AddScoped<MessageRepository>()
.AddSingleton<WebhookExecutorService>()
.AddSingleton<PkMessageHandler>()
.AddSingleton(InMemoryDataService<Snowflake, ChannelCommandData>.Instance)
@ -189,6 +194,8 @@ public static class StartupExtensions
.ServiceProvider.GetRequiredService<IClock>()
.GetCurrentInstant();
DatabasePool.ConfigureDapper();
await using (var db = scope.ServiceProvider.GetRequiredService<DatabaseContext>())
{
var migrationCount = (await db.Database.GetPendingMigrationsAsync()).Count();