File tree Expand file tree Collapse file tree 1 file changed +19
-0
lines changed
Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change 11import logging
2+ import json
23from operator import attrgetter
4+ from sqlalchemy import or_ , not_
35from typing import Any , Optional
46
57import 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
You can’t perform that action at this time.
0 commit comments