From adec9e239ce9d9899c7294e98d0f3d2762d3ec94 Mon Sep 17 00:00:00 2001 From: lismana Date: Thu, 20 Jun 2024 18:44:52 -0400 Subject: [PATCH] Fix case list filtering/counting --- .../mybatisclickhouse/StudyViewMapper.java | 3 +++ .../StudyViewMyBatisRepository.java | 2 ++ .../web/columnar/ClinicalDataBinner.java | 4 ++++ .../StudyViewColumnStoreController.java | 1 + .../StudyViewFilterMapper.xml | 24 +++++++++---------- .../mybatisclickhouse/StudyViewMapper.xml | 6 ++--- 6 files changed, 24 insertions(+), 16 deletions(-) diff --git a/src/main/java/org/cbioportal/persistence/mybatisclickhouse/StudyViewMapper.java b/src/main/java/org/cbioportal/persistence/mybatisclickhouse/StudyViewMapper.java index d7b8aadd199..5d73bb7d037 100644 --- a/src/main/java/org/cbioportal/persistence/mybatisclickhouse/StudyViewMapper.java +++ b/src/main/java/org/cbioportal/persistence/mybatisclickhouse/StudyViewMapper.java @@ -1,15 +1,18 @@ package org.cbioportal.persistence.mybatisclickhouse; +import org.apache.ibatis.annotations.MapKey; import org.cbioportal.model.AlterationCountByGene; import org.cbioportal.model.CaseListDataCount; import org.cbioportal.model.ClinicalData; import org.cbioportal.model.ClinicalDataCount; import org.cbioportal.model.GenomicDataCount; import org.cbioportal.model.Sample; +import org.cbioportal.persistence.helper.AlterationFilterHelper; import org.cbioportal.web.parameter.CategorizedClinicalDataCountFilter; import org.cbioportal.web.parameter.StudyViewFilter; import java.util.List; +import java.util.Map; public interface StudyViewMapper { diff --git a/src/main/java/org/cbioportal/persistence/mybatisclickhouse/StudyViewMyBatisRepository.java b/src/main/java/org/cbioportal/persistence/mybatisclickhouse/StudyViewMyBatisRepository.java index c75f9fe1fa7..cc391cb0481 100644 --- a/src/main/java/org/cbioportal/persistence/mybatisclickhouse/StudyViewMyBatisRepository.java +++ b/src/main/java/org/cbioportal/persistence/mybatisclickhouse/StudyViewMyBatisRepository.java @@ -1,5 +1,6 @@ package org.cbioportal.persistence.mybatisclickhouse; import org.cbioportal.model.AlterationCountByGene; +import org.cbioportal.model.CaseListDataCount; import org.cbioportal.model.ClinicalData; import org.cbioportal.model.ClinicalDataCount; import org.cbioportal.model.GenomicDataCount; @@ -7,6 +8,7 @@ import org.cbioportal.persistence.StudyViewRepository; import org.cbioportal.persistence.enums.ClinicalAttributeDataSource; import org.cbioportal.persistence.enums.ClinicalAttributeDataType; +import org.cbioportal.persistence.helper.AlterationFilterHelper; import org.cbioportal.web.parameter.CategorizedClinicalDataCountFilter; import org.cbioportal.web.parameter.StudyViewFilter; import org.springframework.beans.factory.annotation.Autowired; diff --git a/src/main/java/org/cbioportal/web/columnar/ClinicalDataBinner.java b/src/main/java/org/cbioportal/web/columnar/ClinicalDataBinner.java index 77562cd44d6..ce782118b4a 100644 --- a/src/main/java/org/cbioportal/web/columnar/ClinicalDataBinner.java +++ b/src/main/java/org/cbioportal/web/columnar/ClinicalDataBinner.java @@ -6,6 +6,7 @@ import org.cbioportal.web.parameter.*; import org.cbioportal.web.util.DataBinner; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.cache.annotation.Cacheable; import org.springframework.stereotype.Component; import java.util.*; @@ -26,6 +27,9 @@ public ClinicalDataBinner( this.dataBinner = dataBinner; } + @Cacheable( + cacheResolver = "staticRepositoryCacheOneResolver" + ) public List fetchClinicalDataBinCounts( DataBinMethod dataBinMethod, ClinicalDataBinCountFilter dataBinCountFilter, diff --git a/src/main/java/org/cbioportal/web/columnar/StudyViewColumnStoreController.java b/src/main/java/org/cbioportal/web/columnar/StudyViewColumnStoreController.java index a74715c47ad..69783904337 100644 --- a/src/main/java/org/cbioportal/web/columnar/StudyViewColumnStoreController.java +++ b/src/main/java/org/cbioportal/web/columnar/StudyViewColumnStoreController.java @@ -8,6 +8,7 @@ import jakarta.validation.Valid; import org.cbioportal.model.AlterationCountByGene; import org.cbioportal.model.AlterationFilter; +import org.cbioportal.model.CaseListDataCount; import org.cbioportal.model.ClinicalData; import org.cbioportal.model.ClinicalDataBin; import org.cbioportal.model.ClinicalDataCountItem; diff --git a/src/main/resources/org/cbioportal/persistence/mybatisclickhouse/StudyViewFilterMapper.xml b/src/main/resources/org/cbioportal/persistence/mybatisclickhouse/StudyViewFilterMapper.xml index 2061336b3f2..f6b0953576a 100644 --- a/src/main/resources/org/cbioportal/persistence/mybatisclickhouse/StudyViewFilterMapper.xml +++ b/src/main/resources/org/cbioportal/persistence/mybatisclickhouse/StudyViewFilterMapper.xml @@ -16,21 +16,20 @@ INTERSECT - SELECT sample_unique_id - FROM sample_list_list sll - LEFT JOIN sample_view sv ON sll.sample_id=sv.internal_id - LEFT JOIN sample_list sl on sll.list_id=sl.list_id - - - - - stable_id LIKE '%_${sampleListId}' + SELECT * FROM ( + + SELECT sample_unique_id + FROM sample_list_list sll + LEFT JOIN sample_mv s ON sll.sample_id=s.internal_id + LEFT JOIN sample_list sl on sll.list_id=sl.list_id + WHERE + + sl.stable_id LIKE '%_${list}' - + ) - - + INTERSECT SELECT * FROM ( @@ -50,7 +49,6 @@ gp.stable_id LIKE '%_${genomicProfileId}' - ) diff --git a/src/main/resources/org/cbioportal/persistence/mybatisclickhouse/StudyViewMapper.xml b/src/main/resources/org/cbioportal/persistence/mybatisclickhouse/StudyViewMapper.xml index a7395ab8c5e..4f585d06f9f 100644 --- a/src/main/resources/org/cbioportal/persistence/mybatisclickhouse/StudyViewMapper.xml +++ b/src/main/resources/org/cbioportal/persistence/mybatisclickhouse/StudyViewMapper.xml @@ -129,12 +129,12 @@ REPLACE(stable_id, CONCAT(cancer_study_identifier, '_'), '') AS value, count(sample_id) AS count FROM sample_list_list sll - LEFT JOIN sample_view sv ON sll.sample_id=sv.internal_id - LEFT JOIN sample_list sl on sll.list_id=sl.list_id + LEFT JOIN sample_mv s ON sll.sample_id=s.internal_id + LEFT JOIN sample_list sl on sll.list_id=sl.list_id sample_unique_id IN ( ) - GROUP BY cancer_study_identifier, stable_id, name; + GROUP BY s.cancer_study_identifier, sl.stable_id, sl.name;