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 <noreply@anthropic.com>
This commit is contained in:
12
index.html
12
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: [] }); },
|
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: [] }); },
|
getGroups() { return this.fetch("/api_groups", "public", { fallback: [] }); },
|
||||||
|
|
||||||
getLibraries(base) {
|
async getLibraries(base) {
|
||||||
const config = CONFIG.BASES[base];
|
const config = CONFIG.BASES[base];
|
||||||
if (!config?.hasLibraries) return Promise.resolve([]);
|
if (!config?.hasLibraries) return [];
|
||||||
return this.fetch(`/api_library_list_${base}`, "public", { fallback: [] });
|
// 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) {
|
async getLibraryMembers(base, libraryMrf) {
|
||||||
|
|||||||
Reference in New Issue
Block a user