From 5358a8e803a8d867603e2c5de1f3f1cc21d6111c Mon Sep 17 00:00:00 2001
From: Remi  PLANEL <rplanel@pasteur.fr>
Date: Wed, 5 Jun 2024 17:31:11 +0200
Subject: [PATCH] Fix bug display distry

---
 components/content/RefseqDb.vue | 24 ++++++++++++++----------
 1 file changed, 14 insertions(+), 10 deletions(-)

diff --git a/components/content/RefseqDb.vue b/components/content/RefseqDb.vue
index 850a7470..3a7bb77a 100644
--- a/components/content/RefseqDb.vue
+++ b/components/content/RefseqDb.vue
@@ -227,8 +227,9 @@ const defaultBarPlotOptions = computed(() => {
 // system distri
 
 const computedSystemDistribution = computed(() => {
-    if (toValue(msResult)?.facetDistribution?.type) {
-        return Object.entries(toValue(msResult).facetDistribution.type)
+    const allHitsVal = toValue(allHits)
+    if (allHitsVal?.facetDistribution?.type) {
+        return Object.entries(allHitsVal.facetDistribution.type)
             .map(([key, value]) => {
                 return {
                     type: key,
@@ -264,18 +265,21 @@ const computedDistriSystemOptions = computed(() => {
 // Taxo distri
 const computedTaxonomyDistribution = computed(() => {
     const toValSelectedTaxoRank = toValue(selectedTaxoRank)
-    const toValFacetsPerRank = toValue(msResult)?.facetDistribution?.[toValSelectedTaxoRank]
+    const toValFacetsPerRank = toValue(allHits)?.facetDistribution?.[toValSelectedTaxoRank]
     if (toValFacetsPerRank) {
         const listFacetsPerRank = Object.entries(toValFacetsPerRank)
-        const result = new Array(listFacetsPerRank.length);
-        for (let i = 0; listFacetsPerRank.length; i++) {
-            const [key, value] = listFacetsPerRank[i]
-            result[i] = {
-                [toValSelectedTaxoRank]: key,
-                count: value
+        if (listFacetsPerRank.length > 0) {
+            const result = new Array(listFacetsPerRank.length);
+            for (let i = 0; i < listFacetsPerRank.length; i++) {
+                const [key, value] = listFacetsPerRank[i]
+                result[i] = {
+                    [toValSelectedTaxoRank]: key,
+                    count: value
+                }
             }
+            return result.sort()
         }
-        return result.sort()
+        else { return [] }
     } else { return [] }
 
 })
-- 
GitLab