Clear company cache on startup
Ensures fresh API lookups each time the app starts, avoiding stale cached results that may have been stored before matching improvements. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
using Hangfire;
|
using Hangfire;
|
||||||
using Microsoft.AspNetCore.Components.Authorization;
|
using Microsoft.AspNetCore.Components.Authorization;
|
||||||
using Microsoft.AspNetCore.Identity;
|
using Microsoft.AspNetCore.Identity;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Serilog;
|
using Serilog;
|
||||||
using TrueCV.Infrastructure;
|
using TrueCV.Infrastructure;
|
||||||
using TrueCV.Infrastructure.Data;
|
using TrueCV.Infrastructure.Data;
|
||||||
@@ -70,7 +71,7 @@ try
|
|||||||
|
|
||||||
var app = builder.Build();
|
var app = builder.Build();
|
||||||
|
|
||||||
// Seed default admin user
|
// Seed default admin user and clear company cache
|
||||||
using (var scope = app.Services.CreateScope())
|
using (var scope = app.Services.CreateScope())
|
||||||
{
|
{
|
||||||
var userManager = scope.ServiceProvider.GetRequiredService<UserManager<ApplicationUser>>();
|
var userManager = scope.ServiceProvider.GetRequiredService<UserManager<ApplicationUser>>();
|
||||||
@@ -88,6 +89,16 @@ try
|
|||||||
await userManager.CreateAsync(adminUser, defaultPassword);
|
await userManager.CreateAsync(adminUser, defaultPassword);
|
||||||
Log.Information("Created default admin user: {Email}", defaultEmail);
|
Log.Information("Created default admin user: {Email}", defaultEmail);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Clear company cache on startup to ensure fresh API lookups
|
||||||
|
var dbContext = scope.ServiceProvider.GetRequiredService<ApplicationDbContext>();
|
||||||
|
var cacheCount = await dbContext.CompanyCache.CountAsync();
|
||||||
|
if (cacheCount > 0)
|
||||||
|
{
|
||||||
|
dbContext.CompanyCache.RemoveRange(dbContext.CompanyCache);
|
||||||
|
await dbContext.SaveChangesAsync();
|
||||||
|
Log.Information("Cleared {Count} entries from company cache", cacheCount);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Configure the HTTP request pipeline.
|
// Configure the HTTP request pipeline.
|
||||||
|
|||||||
Reference in New Issue
Block a user