Skip to content

Commit 20b656f

Browse files
committed
Update facet logic for workflow property
1 parent 12c4786 commit 20b656f

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

nmdc_server/query.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -789,6 +789,22 @@ def facet(self, db: Session, attribute: str) -> Dict[schemas.AnnotationValue, in
789789
annotations_column["omics_type"].astext,
790790
).group_by(annotations_column["omics_type"].astext)
791791
return {value: count for count, value in aggregated_query if value is not None}
792+
if attribute == "metaproteomics_analysis_category":
793+
association_table = models.metaproteomic_analysis_data_generation_association
794+
query = self.query(db)
795+
query = query.join(
796+
association_table,
797+
models.OmicsProcessing.id == association_table.c.data_generation_id,
798+
)
799+
query = query.join(
800+
models.MetaproteomicAnalysis,
801+
models.MetaproteomicAnalysis.id == association_table.c.metaproteomic_analysis_id,
802+
)
803+
aggregated_query = query.with_entities(
804+
func.count(func.distinct(models.OmicsProcessing.id)).label("id_count"),
805+
models.MetaproteomicAnalysis.metaproteomics_analysis_category,
806+
).group_by(models.MetaproteomicAnalysis.metaproteomics_analysis_category)
807+
return {value: count for count, value in aggregated_query if value is not None}
792808
return super().facet(db, attribute)
793809

794810
def omics_processing_for_biosample_ids(self, db: Session, biosample_ids):

0 commit comments

Comments
 (0)