Skip to content

Commit d464740

Browse files
committed
Not showing meta-analysis experiments in creating score set dropdown menu.
1 parent 1621dd0 commit d464740

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

src/mavedb/routers/experiments.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import logging
2+
import json
23
from operator import attrgetter
4+
from sqlalchemy import or_, not_
35
from typing import Any, Optional
46

57
import pydantic
@@ -75,6 +77,23 @@ def list_experiments(
7577
) # .filter(Experiment.published_date is None)
7678
# else:
7779
# query = query.filter(Experiment.created_by_id == user.id).filter(Experiment.published_date is None)
80+
try:
81+
q_parsed = json.loads(q)
82+
l_filter = q_parsed.get('l', {}).get('meta_analysis', None)
83+
84+
if l_filter == 'false':
85+
logger.debug("Excluding meta-analysis experiments.")
86+
query = query.filter(
87+
or_(
88+
# Keep experiments without any score sets
89+
not_(Experiment.score_sets.any()),
90+
# Keep experiments where score sets exist but have no meta_analyzes_score_sets
91+
Experiment.score_sets.any(not_(ScoreSet.meta_analyzes_score_sets.any()))
92+
)
93+
)
94+
95+
except json.JSONDecodeError:
96+
raise HTTPException(status_code=400, detail="Invalid query format")
7897
else:
7998
logger.debug(msg="No query string was provided; Listing all experiments.", extra=logging_context())
8099

0 commit comments

Comments
 (0)