Fix: Lost Enpoint

This commit is contained in:
2025-07-17 13:58:26 -03:00
parent f087799191
commit aadd0b218b
3 changed files with 19 additions and 5 deletions

View File

@@ -38,9 +38,7 @@ namespace Mercados.Api.Controllers
{
try
{
var hoy = DateOnly.FromDateTime(DateTime.UtcNow);
var data = await _ganadoRepo.ObtenerTandaPorFechaAsync(hoy);
var data = await _ganadoRepo.ObtenerUltimaTandaDisponibleAsync();
return Ok(data);
}
catch (Exception ex)

View File

@@ -13,6 +13,22 @@ namespace Mercados.Infrastructure.Persistence.Repositories
_connectionFactory = connectionFactory;
}
public async Task<IEnumerable<CotizacionGanado>> ObtenerUltimaTandaDisponibleAsync()
{
using IDbConnection connection = _connectionFactory.CreateConnection();
// Esta consulta busca la fecha más reciente que tiene registros
// y luego devuelve todos los registros de esa fecha. Es la lógica original y correcta.
const string sql = @"
SELECT * FROM CotizacionesGanado
WHERE CONVERT(date, FechaRegistro) = (
SELECT TOP 1 CONVERT(date, FechaRegistro)
FROM CotizacionesGanado
ORDER BY FechaRegistro DESC
);";
return await connection.QueryAsync<CotizacionGanado>(sql);
}
// Este método lo sigue necesitando el Fetcher para comparar los datos del día.
public async Task<IEnumerable<CotizacionGanado>> ObtenerTandaPorFechaAsync(DateOnly fecha)
{
using IDbConnection connection = _connectionFactory.CreateConnection();

View File

@@ -4,9 +4,9 @@ namespace Mercados.Infrastructure.Persistence.Repositories
{
public interface ICotizacionGanadoRepository : IBaseRepository
{
Task<IEnumerable<CotizacionGanado>> ObtenerTandaPorFechaAsync(DateOnly fecha);
Task GuardarMuchosAsync(IEnumerable<CotizacionGanado> cotizaciones);
Task<IEnumerable<CotizacionGanado>> ObtenerUltimaTandaDisponibleAsync();
Task ReemplazarTandaDelDiaAsync(DateOnly fecha, IEnumerable<CotizacionGanado> nuevasCotizaciones);
Task<IEnumerable<CotizacionGanado>> ObtenerHistorialAsync(string categoria, string especificaciones, int dias);
Task<IEnumerable<CotizacionGanado>> ObtenerTandaPorFechaAsync(DateOnly fecha);
}
}