|
43 | 43 | def _load(query: sa.Select): |
44 | 44 | return query.options( |
45 | 45 | joinedload(Circuit.license), |
46 | | - joinedload(Circuit.subject).joinedload(Subject.species), |
47 | | - joinedload(Circuit.subject).joinedload(Subject.strain), |
| 46 | + joinedload(Circuit.subject).options( |
| 47 | + joinedload(Subject.species), |
| 48 | + joinedload(Subject.strain), |
| 49 | + ), |
48 | 50 | joinedload(Circuit.brain_region), |
49 | 51 | joinedload(Circuit.created_by), |
50 | 52 | joinedload(Circuit.updated_by), |
51 | | - selectinload(Circuit.contributions).joinedload(Contribution.agent), |
52 | | - selectinload(Circuit.contributions).joinedload(Contribution.role), |
| 53 | + selectinload(Circuit.contributions).options( |
| 54 | + joinedload(Contribution.agent), |
| 55 | + joinedload(Contribution.role), |
| 56 | + ), |
53 | 57 | selectinload(Circuit.assets), |
54 | 58 | raiseload("*"), |
55 | 59 | ) |
@@ -141,22 +145,30 @@ def read_many( |
141 | 145 | facets: FacetsDep, |
142 | 146 | in_brain_region: InBrainRegionDep, |
143 | 147 | ) -> ListResponse[CircuitRead]: |
| 148 | + subject_alias = aliased(Subject, flat=True) |
144 | 149 | agent_alias = aliased(Agent, flat=True) |
145 | 150 | created_by_alias = aliased(Agent, flat=True) |
146 | 151 | updated_by_alias = aliased(Agent, flat=True) |
147 | 152 |
|
148 | 153 | aliases: Aliases = { |
| 154 | + Subject: subject_alias, |
149 | 155 | Agent: { |
150 | 156 | "contribution": agent_alias, |
151 | 157 | "created_by": created_by_alias, |
152 | 158 | "updated_by": updated_by_alias, |
153 | | - } |
| 159 | + }, |
154 | 160 | } |
155 | | - facet_keys = filter_keys = [ |
| 161 | + facet_keys = [ |
156 | 162 | "brain_region", |
157 | 163 | "created_by", |
158 | 164 | "updated_by", |
159 | 165 | "contribution", |
| 166 | + "subject.species", |
| 167 | + "subject.strain", |
| 168 | + ] |
| 169 | + filter_keys = [ |
| 170 | + "subject", |
| 171 | + *facet_keys, |
160 | 172 | ] |
161 | 173 | name_to_facet_query_params, filter_joins = query_params_factory( |
162 | 174 | db_model_class=Circuit, |
|
0 commit comments