From ab9c6ea6022168ab442fe81d8356525b68b653c1 Mon Sep 17 00:00:00 2001 From: Gaofei Zhao Date: Fri, 10 Dec 2021 16:03:29 -0500 Subject: [PATCH] Do not fetch structural variants data when there are no applicable samples --- src/pages/resultsView/ResultsViewPageStore.ts | 27 ++++++++++++------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/src/pages/resultsView/ResultsViewPageStore.ts b/src/pages/resultsView/ResultsViewPageStore.ts index dc186430601..20dfdd54517 100644 --- a/src/pages/resultsView/ResultsViewPageStore.ts +++ b/src/pages/resultsView/ResultsViewPageStore.ts @@ -3177,17 +3177,24 @@ export class ResultsViewPageStore [] as StructuralVariantFilter['sampleMolecularIdentifiers'] ); - const data = { - entrezGeneIds: _.map( - this.genes.result, - (gene: Gene) => gene.entrezGeneId - ), - sampleMolecularIdentifiers: filters, - } as StructuralVariantFilter; + // filters can be an empty list + // when all selected samples are coming from studies that don't have structural variant profile + // in this case, we should not fetch structural variants data + if (_.isEmpty(filters)) { + return []; + } else { + const data = { + entrezGeneIds: _.map( + this.genes.result, + (gene: Gene) => gene.entrezGeneId + ), + sampleMolecularIdentifiers: filters, + } as StructuralVariantFilter; - return await client.fetchStructuralVariantsUsingPOST({ - structuralVariantFilter: data, - }); + return await client.fetchStructuralVariantsUsingPOST({ + structuralVariantFilter: data, + }); + } }, });