diff --git a/components/AutocompleteMeiliFacets.vue b/components/AutocompleteMeiliFacets.vue index 23a375932e4f6f738b2af952da8bff0dfc25ad37..e0023f4035b6801d528c39118c1232ed4ef9ae04 100644 --- a/components/AutocompleteMeiliFacets.vue +++ b/components/AutocompleteMeiliFacets.vue @@ -106,6 +106,7 @@ const autocompleteItems = computed(() => { title: facetItem.title, deletable: false, icon: facetItem?.icon, + count: facetItem?.count, props: { deletable: false, type: "facet" diff --git a/components/ServerDbTable.vue b/components/ServerDbTable.vue index 394f7b2085af5e4512cd22f39f43944f6f1d80d5..d1b73240329bd8c8406e173a75cd5d42f7a44d81 100644 --- a/components/ServerDbTable.vue +++ b/components/ServerDbTable.vue @@ -387,7 +387,7 @@ function focusedOrBlur(isFocused: boolean) { </v-autocomplete> </v-toolbar> --> <v-toolbar> - <AutocompleteMeiliFacets v-model="msFilterCompo" :db="props.db" :facets="$props.facets" + <AutocompleteMeiliFacets v-model="msFilterCompo" :db="props.db" :facets="props.facets" :facet-distribution="props.facetDistribution" @update:modelValue="emitRefreshRes"> </AutocompleteMeiliFacets> </v-toolbar> diff --git a/components/content/RefseqDb.vue b/components/content/RefseqDb.vue index 0cabed60031cbfdaf92d5a4c6722ca2b9a315146..72a05af162f6c15fc66583242dff8291158cced9 100644 --- a/components/content/RefseqDb.vue +++ b/components/content/RefseqDb.vue @@ -19,9 +19,25 @@ const dbName = ref("refseq") const scaleTransform: Ref<string[]> = ref([]) const facetDistribution: Ref<Record<string, Record<string, number>> | undefined> = ref(undefined) -await callOnce(async () => { +// await callOnce(async () => { - console.log("dans le call once") +// console.log("dans le call once") +// const { data } = await useAsyncMeiliSearch({ +// index: toValue(dbName), query: "", params: { +// facets: ["*"], +// filter: [], +// page: 1, +// hitsPerPage: 25, +// } +// }) +// console.log(data) + + + +// facetDistribution.value = toValue(data)?.facetDistribution +// }) +onUpdated(async () => { + console.log("dans le mounted refseq") const { data } = await useAsyncMeiliSearch({ index: toValue(dbName), query: "", params: { facets: ["*"], @@ -30,13 +46,29 @@ await callOnce(async () => { hitsPerPage: 25, } }) - console.log(data) + console.log(toValue(data)) + facetDistribution.value = toValue(data)?.facetDistribution +}) +onMounted(async () => { + console.log("dans le mounted refseq") + const { data } = await useAsyncMeiliSearch({ + index: toValue(dbName), query: "", params: { + facets: ["*"], + filter: [], + page: 1, + hitsPerPage: 25, + } + }) + console.log(toValue(data)) facetDistribution.value = toValue(data)?.facetDistribution + }) -onMounted(async () => { + + +onBeforeMount(async () => { console.log("dans le mounted refseq") const { data } = await useAsyncMeiliSearch({ index: toValue(dbName), query: "", params: { @@ -80,7 +112,7 @@ const computedFacets = computed(() => { const toValFacetDistribution = toValue(facetDistribution) console.log(toValFacetDistribution) return toValue(facets).map(facet => { - const count = toValFacetDistribution?.[facet.value] ? Object.values(toValFacetDistribution[facet.value]).reduce((acc, curr) => { return acc + curr }, 0) : undefined + const count = toValFacetDistribution?.[facet.value] ? Object.keys(toValFacetDistribution[facet.value]).length : undefined return count ? { ...facet, count } : { ...facet } })