From 964b7820f768ea4453195d7e60622dcb7c9a9914 Mon Sep 17 00:00:00 2001 From: ARCHITECT Date: Sat, 17 Jan 2026 22:01:40 +0000 Subject: [PATCH] Fix getLibraries to query library tables directly Instead of depending on non-existent api_library_list_* views, now queries library_${base} for unique mrf_library values and fetches tag info from main table. Co-Authored-By: Claude Opus 4.5 --- index.html | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/index.html b/index.html index 8eda822..8d88538 100644 --- a/index.html +++ b/index.html @@ -901,10 +901,16 @@ const API = { getHstTags() { return this.fetch("/hst?select=mrf,ref,name_es,name_en,alias", "tzzr_core_hst", { fallback: [] }); }, getGroups() { return this.fetch("/api_groups", "public", { fallback: [] }); }, - getLibraries(base) { + async getLibraries(base) { const config = CONFIG.BASES[base]; - if (!config?.hasLibraries) return Promise.resolve([]); - return this.fetch(`/api_library_list_${base}`, "public", { fallback: [] }); + if (!config?.hasLibraries) return []; + // Get unique library MRFs from library_${base} + const relations = await this.fetch(`/library_${base}?select=mrf_library`, config.schema, { fallback: [] }); + const uniqueMrfs = [...new Set(relations.map(r => r.mrf_library))]; + if (uniqueMrfs.length === 0) return []; + // Fetch tag info for those MRFs + const mrfFilter = uniqueMrfs.map(m => `"${m}"`).join(','); + return this.fetch(`/${config.table}?mrf=in.(${mrfFilter})&select=mrf,alias,name_es,name_en,img_thumb_url`, config.schema, { fallback: [] }); }, async getLibraryMembers(base, libraryMrf) {