fix issues

This commit is contained in:
Leonid Pershin
2025-10-17 03:09:11 +03:00
parent 392e6bc7f5
commit 7c17127d12
4 changed files with 11 additions and 5 deletions

View File

@@ -149,7 +149,7 @@ namespace ChatBot.Data.Repositories
.ChatSessions.Where(s => s.LastUpdatedAt < cutoffTime)
.ToListAsync();
if (sessionsToRemove.Any())
if (sessionsToRemove.Count > 0)
{
_context.ChatSessions.RemoveRange(sessionsToRemove);
await _context.SaveChangesAsync();

View File

@@ -153,10 +153,13 @@ try
);
// Регистрируем Health Checks
var ollamaTags = new[] { "api", "ollama" };
var telegramTags = new[] { "api", "telegram" };
builder
.Services.AddHealthChecks()
.AddCheck<OllamaHealthCheck>("ollama", tags: new[] { "api", "ollama" })
.AddCheck<TelegramBotHealthCheck>("telegram", tags: new[] { "api", "telegram" });
.AddCheck<OllamaHealthCheck>("ollama", tags: ollamaTags)
.AddCheck<TelegramBotHealthCheck>("telegram", tags: telegramTags);
var host = builder.Build();

View File

@@ -54,7 +54,10 @@ namespace ChatBot.Services
when (ex.Message.Contains("database") && ex.Message.Contains("does not exist"))
{
// This is expected when database doesn't exist - MigrateAsync will create it
_logger.LogInformation("Database does not exist, will be created during migration");
_logger.LogInformation(
ex,
"Database does not exist, will be created during migration"
);
await context.Database.MigrateAsync(cancellationToken);
_logger.LogInformation("Database initialization completed successfully");
}

View File

@@ -29,7 +29,7 @@ namespace ChatBot.Services.Telegram.Commands
var commandRegistry = _serviceProvider.GetRequiredService<CommandRegistry>();
var commands = commandRegistry.GetCommandsWithDescriptions().ToList();
if (!commands.Any())
if (commands.Count == 0)
{
return Task.FromResult("❌ Команды не найдены.");
}