diff --git a/nuxt4-app/app/pages/metabase-debug.vue b/nuxt4-app/app/pages/metabase-debug.vue index 92daeea..5dcbabe 100644 --- a/nuxt4-app/app/pages/metabase-debug.vue +++ b/nuxt4-app/app/pages/metabase-debug.vue @@ -23,7 +23,7 @@ -
+
{{ cards.length }}
@@ -47,10 +47,17 @@
-
{{ panoramaQueries.length }}/9
+
{{ panoramaQueries.length }}/9
Queries Panorama
+ + +
+
{{ informeQueries.length }}/8
+
Queries Informe
+
+
@@ -96,7 +103,7 @@ color="info" variant="soft" title="Queries del Panorama Facturador" - description="Estas son las 9 queries documentadas en METABASE_QUERIES_PANORAMA.md" + description="Estas son las 9 queries documentadas en METABASE_QUERIES_PANORAMA.md y definidas en server/config/metabase-queries.ts" />
@@ -112,7 +119,35 @@ color="warning" variant="soft" :title="`Faltan ${9 - panoramaQueries.length} queries por encontrar`" - description="Busca en la tabla las queries que contengan 'panorama' en su nombre" + :description="`Queries faltantes: ${missingPanoramaQueries.join(', ')}`" + /> +
+ + + + @@ -140,6 +175,21 @@ const cards = ref([]) const selectedCard = ref(null) const selectedTab = ref(0) +// Get expected query names from centralized config (via API) +const expectedPanoramaNames = ref([]) +const expectedInformeNames = ref([]) + +// Fetch query config on mount +async function fetchQueryConfig() { + try { + const config = await $fetch('/api/metabase/query-config') + expectedPanoramaNames.value = config.panorama + expectedInformeNames.value = config.informe + } catch (e: any) { + console.error('Error fetching query config:', e) + } +} + const tabs = [ { key: 'table', @@ -159,6 +209,12 @@ const tabs = [ icon: 'i-heroicons-chart-bar', slot: 'panorama' }, + { + key: 'informe', + label: 'Queries Informe', + icon: 'i-heroicons-document-chart-bar', + slot: 'informe' + }, { key: 'detail', label: 'Detalle', @@ -182,12 +238,31 @@ const queryBuilderQueries = computed(() => { }).length }) +// Find panorama queries using centralized config const panoramaQueries = computed(() => { return cards.value.filter(card => - card.name?.toLowerCase().includes('panorama') + expectedPanoramaNames.value.includes(card.name) ) }) +// Find informe queries using centralized config +const informeQueries = computed(() => { + return cards.value.filter(card => + expectedInformeNames.value.includes(card.name) + ) +}) + +// Calculate missing queries +const missingPanoramaQueries = computed(() => { + const foundNames = panoramaQueries.value.map(q => q.name) + return expectedPanoramaNames.value.filter(name => !foundNames.includes(name)) +}) + +const missingInformeQueries = computed(() => { + const foundNames = informeQueries.value.map(q => q.name) + return expectedInformeNames.value.filter(name => !foundNames.includes(name)) +}) + async function fetchCards() { loading.value = true error.value = null @@ -209,11 +284,12 @@ function refreshCards() { function selectCard(card: any) { selectedCard.value = card - selectedTab.value = 3 // Switch to detail tab + selectedTab.value = 4 // Switch to detail tab (now index 4 instead of 3) } -// Load cards on mount -onMounted(() => { - fetchCards() +// Load data on mount +onMounted(async () => { + await fetchQueryConfig() + await fetchCards() }) diff --git a/nuxt4-app/server/api/metabase/query-config.get.ts b/nuxt4-app/server/api/metabase/query-config.get.ts new file mode 100644 index 0000000..53abe20 --- /dev/null +++ b/nuxt4-app/server/api/metabase/query-config.get.ts @@ -0,0 +1,12 @@ +import { METABASE_QUERIES } from '../../config/metabase-queries' + +/** + * Expose query configuration to the frontend + * Returns the expected query names for panorama and informe + */ +export default defineEventHandler(() => { + return { + panorama: Object.values(METABASE_QUERIES.panorama), + informe: Object.values(METABASE_QUERIES.informe) + } +})