Fix Worker 1524
This commit is contained in:
		| @@ -225,16 +225,18 @@ public class Worker : BackgroundService | |||||||
|             using var scope = _serviceProvider.CreateScope(); |             using var scope = _serviceProvider.CreateScope(); | ||||||
|             var dbContext = scope.ServiceProvider.GetRequiredService<EleccionesDbContext>(); |             var dbContext = scope.ServiceProvider.GetRequiredService<EleccionesDbContext>(); | ||||||
|  |  | ||||||
|  |             // Cambiamos la búsqueda a NivelId = 30, que según la API | ||||||
|  |             // son los registros de "Sección" (Partidos/Municipios). | ||||||
|             var municipiosASondear = await dbContext.AmbitosGeograficos |             var municipiosASondear = await dbContext.AmbitosGeograficos | ||||||
|             .AsNoTracking() |             .AsNoTracking() | ||||||
|                 .Where(a => a.NivelId == 5 && a.MunicipioId != null && a.DistritoId != null && a.SeccionId != null) |             .Where(a => a.NivelId == 30 && a.MunicipioId != null && a.DistritoId != null && a.SeccionId != null) | ||||||
|                 // Añadimos a.Nombre aquí para que esté disponible en el bucle |  | ||||||
|             .Select(a => new { a.Id, a.Nombre, a.MunicipioId, a.SeccionId, a.DistritoId }) |             .Select(a => new { a.Id, a.Nombre, a.MunicipioId, a.SeccionId, a.DistritoId }) | ||||||
|             .ToListAsync(stoppingToken); |             .ToListAsync(stoppingToken); | ||||||
|  |  | ||||||
|             if (!municipiosASondear.Any()) |             if (!municipiosASondear.Any()) | ||||||
|             { |             { | ||||||
|                 _logger.LogWarning("No se encontraron Partidos (NivelId 5) en la BD para sondear resultados."); |                 // Este log ahora mostrará 'NivelId 30' si falla. | ||||||
|  |                 _logger.LogWarning("No se encontraron Partidos (NivelId 30) en la BD para sondear resultados."); | ||||||
|                 return; |                 return; | ||||||
|             } |             } | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user