From 7c17127d12f0784fe7ac313edfd663e0b32a6385 Mon Sep 17 00:00:00 2001 From: Leonid Pershin Date: Fri, 17 Oct 2025 03:09:11 +0300 Subject: [PATCH] fix issues --- ChatBot/Data/Repositories/ChatSessionRepository.cs | 2 +- ChatBot/Program.cs | 7 +++++-- ChatBot/Services/DatabaseInitializationService.cs | 5 ++++- ChatBot/Services/Telegram/Commands/HelpCommand.cs | 2 +- 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/ChatBot/Data/Repositories/ChatSessionRepository.cs b/ChatBot/Data/Repositories/ChatSessionRepository.cs index c3e129f..656012c 100644 --- a/ChatBot/Data/Repositories/ChatSessionRepository.cs +++ b/ChatBot/Data/Repositories/ChatSessionRepository.cs @@ -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(); diff --git a/ChatBot/Program.cs b/ChatBot/Program.cs index 78b8efd..64df4f8 100644 --- a/ChatBot/Program.cs +++ b/ChatBot/Program.cs @@ -153,10 +153,13 @@ try ); // Регистрируем Health Checks + var ollamaTags = new[] { "api", "ollama" }; + var telegramTags = new[] { "api", "telegram" }; + builder .Services.AddHealthChecks() - .AddCheck("ollama", tags: new[] { "api", "ollama" }) - .AddCheck("telegram", tags: new[] { "api", "telegram" }); + .AddCheck("ollama", tags: ollamaTags) + .AddCheck("telegram", tags: telegramTags); var host = builder.Build(); diff --git a/ChatBot/Services/DatabaseInitializationService.cs b/ChatBot/Services/DatabaseInitializationService.cs index 8381d86..2eaa425 100644 --- a/ChatBot/Services/DatabaseInitializationService.cs +++ b/ChatBot/Services/DatabaseInitializationService.cs @@ -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"); } diff --git a/ChatBot/Services/Telegram/Commands/HelpCommand.cs b/ChatBot/Services/Telegram/Commands/HelpCommand.cs index 5dd6ada..bba0df0 100644 --- a/ChatBot/Services/Telegram/Commands/HelpCommand.cs +++ b/ChatBot/Services/Telegram/Commands/HelpCommand.cs @@ -29,7 +29,7 @@ namespace ChatBot.Services.Telegram.Commands var commandRegistry = _serviceProvider.GetRequiredService(); var commands = commandRegistry.GetCommandsWithDescriptions().ToList(); - if (!commands.Any()) + if (commands.Count == 0) { return Task.FromResult("❌ Команды не найдены."); }