Fix: corregir tipos de parámetros para queries nativas SQL de Metabase
All checks were successful
build-and-deploy / build-and-deploy (push) Successful in 47s

Cambios principales:
- Cambiar tipo de parámetros de fecha de 'date/single' a 'text'
- Cambiar tipo de parámetro booleano de 'category' a 'boolean'
- Cambiar tipo de parámetros de categoría de 'category' a 'text'

Las queries SQL nativas en Metabase usan template-tags con tipos específicos
que deben coincidir exactamente con el tipo definido en el template-tag,
no con los tipos de UI de Metabase.

Archivos modificados:
- server/api/metabase/panorama.post.ts
- server/api/metabase/informe.post.ts

Resuelve el problema donde todas las queries retornaban error 500 y
respuestas vacías debido a tipos de parámetros incompatibles.
This commit is contained in:
2025-10-29 10:32:10 -06:00
parent b4ec8d5444
commit ce7bec7d4c
2 changed files with 13 additions and 13 deletions

View File

@@ -38,21 +38,21 @@ export default defineEventHandler(async (event) => {
} }
// Build parameters array for Metabase queries // Build parameters array for Metabase queries
// Convertir null a string vacío para que las queries usen NULLIF correctamente // Las queries SQL nativas usan template-tags de tipo 'text' para fechas, no 'date/single'
const buildParameters = (includeGranularidad: boolean = false) => { const buildParameters = (includeGranularidad: boolean = false) => {
const params = [ const params = [
{ {
type: 'date/single', type: 'text',
target: ['variable', ['template-tag', 'fecha_desde']], target: ['variable', ['template-tag', 'fecha_desde']],
value: fecha_desde || '' value: fecha_desde || ''
}, },
{ {
type: 'date/single', type: 'text',
target: ['variable', ['template-tag', 'fecha_hasta']], target: ['variable', ['template-tag', 'fecha_hasta']],
value: fecha_hasta || '' value: fecha_hasta || ''
}, },
{ {
type: 'category', type: 'boolean',
target: ['variable', ['template-tag', 'incluir_anulados']], target: ['variable', ['template-tag', 'incluir_anulados']],
value: incluir_anulados value: incluir_anulados
}, },
@@ -62,22 +62,22 @@ export default defineEventHandler(async (event) => {
value: cliente_ids value: cliente_ids
}, },
{ {
type: 'category', type: 'text',
target: ['variable', ['template-tag', 'tipos']], target: ['variable', ['template-tag', 'tipos']],
value: tipos value: tipos
}, },
{ {
type: 'category', type: 'text',
target: ['variable', ['template-tag', 'estados']], target: ['variable', ['template-tag', 'estados']],
value: estados value: estados
}, },
{ {
type: 'category', type: 'text',
target: ['variable', ['template-tag', 'ubicaciones']], target: ['variable', ['template-tag', 'ubicaciones']],
value: ubicaciones value: ubicaciones
}, },
{ {
type: 'category', type: 'text',
target: ['variable', ['template-tag', 'calidades']], target: ['variable', ['template-tag', 'calidades']],
value: calidades value: calidades
} }
@@ -85,7 +85,7 @@ export default defineEventHandler(async (event) => {
if (includeGranularidad) { if (includeGranularidad) {
params.push({ params.push({
type: 'category', type: 'text',
target: ['variable', ['template-tag', 'granularidad']], target: ['variable', ['template-tag', 'granularidad']],
value: granularidad value: granularidad
}) })

View File

@@ -34,20 +34,20 @@ export default defineEventHandler(async (event) => {
console.log('[Panorama] Cards to execute:', Object.keys(cards)) console.log('[Panorama] Cards to execute:', Object.keys(cards))
// Build parameters array for Metabase queries // Build parameters array for Metabase queries
// Convertir null a string vacío para que las queries usen NULLIF correctamente // Las queries SQL nativas usan template-tags de tipo 'text' para fechas, no 'date/single'
const parameters = [ const parameters = [
{ {
type: 'date/single', type: 'text',
target: ['variable', ['template-tag', 'fecha_desde']], target: ['variable', ['template-tag', 'fecha_desde']],
value: fecha_desde || '' value: fecha_desde || ''
}, },
{ {
type: 'date/single', type: 'text',
target: ['variable', ['template-tag', 'fecha_hasta']], target: ['variable', ['template-tag', 'fecha_hasta']],
value: fecha_hasta || '' value: fecha_hasta || ''
}, },
{ {
type: 'category', type: 'boolean',
target: ['variable', ['template-tag', 'incluir_anulados']], target: ['variable', ['template-tag', 'incluir_anulados']],
value: incluir_anulados value: incluir_anulados
} }