Fix: Ejecutar query metadata_cosechas sin parámetros
All checks were successful
build-and-deploy / build-and-deploy (push) Successful in 52s
All checks were successful
build-and-deploy / build-and-deploy (push) Successful in 52s
Query 59 (metadata_cosechas) no necesita parámetros porque devuelve todas las cosechas disponibles, no solo las seleccionadas. Pasarle parámetros causa que devuelva datos vacíos.
This commit is contained in:
@@ -49,15 +49,15 @@ export default defineEventHandler(async (event) => {
|
|||||||
]
|
]
|
||||||
|
|
||||||
// Execute all queries in parallel with error handling
|
// Execute all queries in parallel with error handling
|
||||||
const executeWithErrorHandling = async (name: string, cardId: number | undefined, defaultValue: any) => {
|
const executeWithErrorHandling = async (name: string, cardId: number | undefined, defaultValue: any, params: any[] = parameters) => {
|
||||||
if (!cardId) {
|
if (!cardId) {
|
||||||
console.warn(`[Comparativa] No card ID for ${name}`)
|
console.warn(`[Comparativa] No card ID for ${name}`)
|
||||||
return defaultValue
|
return defaultValue
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
console.log(`[Comparativa] Executing query: ${name} (ID: ${cardId}) with params:`, JSON.stringify(parameters))
|
console.log(`[Comparativa] Executing query: ${name} (ID: ${cardId}) with params:`, JSON.stringify(params))
|
||||||
const result = await executeCardQuery(cardId, parameters)
|
const result = await executeCardQuery(cardId, params)
|
||||||
console.log(`[Comparativa] Query ${name} result:`, {
|
console.log(`[Comparativa] Query ${name} result:`, {
|
||||||
hasData: !!result.data,
|
hasData: !!result.data,
|
||||||
rowsLength: result.data?.rows?.length || 0,
|
rowsLength: result.data?.rows?.length || 0,
|
||||||
@@ -80,7 +80,7 @@ export default defineEventHandler(async (event) => {
|
|||||||
executeWithErrorHandling('datosDiariosCompletos', cards.datos_diarios_completos?.id, { data: { rows: [], cols: [] } }),
|
executeWithErrorHandling('datosDiariosCompletos', cards.datos_diarios_completos?.id, { data: { rows: [], cols: [] } }),
|
||||||
executeWithErrorHandling('totalesPorCosecha', cards.totales_por_cosecha?.id, { data: { rows: [], cols: [] } }),
|
executeWithErrorHandling('totalesPorCosecha', cards.totales_por_cosecha?.id, { data: { rows: [], cols: [] } }),
|
||||||
executeWithErrorHandling('datosAcumuladosPorDia', cards.datos_acumulados_por_dia?.id, { data: { rows: [], cols: [] } }),
|
executeWithErrorHandling('datosAcumuladosPorDia', cards.datos_acumulados_por_dia?.id, { data: { rows: [], cols: [] } }),
|
||||||
executeWithErrorHandling('metadataCosechas', cards.metadata_cosechas?.id, { data: { rows: [], cols: [] } })
|
executeWithErrorHandling('metadataCosechas', cards.metadata_cosechas?.id, { data: { rows: [], cols: [] } }, []) // Sin parámetros
|
||||||
])
|
])
|
||||||
|
|
||||||
// Transform Metabase responses to objects for easier frontend consumption
|
// Transform Metabase responses to objects for easier frontend consumption
|
||||||
|
|||||||
Reference in New Issue
Block a user