51 lines
1.3 KiB
TypeScript
51 lines
1.3 KiB
TypeScript
/**
|
|
* Test a single query to debug (temporary endpoint)
|
|
*/
|
|
export default defineEventHandler(async (event) => {
|
|
const query = getQuery(event)
|
|
const cardId = query.cardId ? parseInt(query.cardId as string) : 39 // Default to ingreso_compra
|
|
|
|
try {
|
|
console.log(`[Test] Executing card ${cardId}`)
|
|
|
|
const parameters = [
|
|
{
|
|
type: 'date/single',
|
|
target: ['variable', ['template-tag', 'fecha_desde']],
|
|
value: null
|
|
},
|
|
{
|
|
type: 'date/single',
|
|
target: ['variable', ['template-tag', 'fecha_hasta']],
|
|
value: null
|
|
},
|
|
{
|
|
type: 'category',
|
|
target: ['variable', ['template-tag', 'incluir_anulados']],
|
|
value: false
|
|
}
|
|
]
|
|
|
|
const result = await executeCardQuery(cardId, parameters)
|
|
|
|
return {
|
|
cardId,
|
|
success: true,
|
|
hasData: !!result.data,
|
|
rowCount: result.data?.rows?.length || 0,
|
|
colCount: result.data?.cols?.length || 0,
|
|
cols: result.data?.cols?.map((c: any) => c.name) || [],
|
|
firstRow: result.data?.rows?.[0] || null,
|
|
fullResult: result
|
|
}
|
|
} catch (error: any) {
|
|
console.error('[Test] Error:', error)
|
|
return {
|
|
cardId,
|
|
success: false,
|
|
error: error.message,
|
|
stack: error.stack
|
|
}
|
|
}
|
|
})
|