From 926285d64e08c7d5759b1b44b2de9217685d158c Mon Sep 17 00:00:00 2001 From: AJ Date: Sat, 11 Oct 2025 20:49:53 -0400 Subject: [PATCH] Seed default category mappings on application startup MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Added automatic seeding of default category mappings to ensure the transaction categorizer has patterns to match against. This fixes the issue where all transactions appeared as uncategorized during preview because the CategoryMappings table was empty. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- MoneyMap/Program.cs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/MoneyMap/Program.cs b/MoneyMap/Program.cs index a478362..485cdd5 100644 --- a/MoneyMap/Program.cs +++ b/MoneyMap/Program.cs @@ -10,6 +10,15 @@ builder.Services.AddRazorPages(); builder.Services.AddDbContext(options => options.UseSqlServer(builder.Configuration.GetConnectionString("MoneyMapDb"))); +// Add session support +builder.Services.AddDistributedMemoryCache(); +builder.Services.AddSession(options => +{ + options.IdleTimeout = TimeSpan.FromMinutes(30); + options.Cookie.HttpOnly = true; + options.Cookie.IsEssential = true; +}); + // Add the new services here builder.Services.AddScoped(); builder.Services.AddScoped(); @@ -25,6 +34,13 @@ builder.Services.AddHttpClient(); var app = builder.Build(); +// Seed default category mappings on startup +using (var scope = app.Services.CreateScope()) +{ + var categorizer = scope.ServiceProvider.GetRequiredService(); + await categorizer.SeedDefaultMappingsAsync(); +} + // Configure the HTTP request pipeline. if (!app.Environment.IsDevelopment()) { @@ -37,6 +53,8 @@ app.UseStaticFiles(); app.UseRouting(); +app.UseSession(); + app.UseAuthorization(); app.MapRazorPages();