Skip to content

Commit cf48cad

Browse files
committed
add constructor for setting BatchIdQuery target field
1 parent 97f7a75 commit cf48cad

2 files changed

Lines changed: 5 additions & 6 deletions

File tree

emmet-api/emmet/api/routes/materials/materials/query_operators.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -474,6 +474,9 @@ def query(
474474
class BatchIdQuery(QueryOperator):
475475
"""Method to generate a query on batch_id"""
476476

477+
def __init__(self, field="builder_meta.batch_id"):
478+
self._field = field
479+
477480
def query(
478481
self,
479482
batch_id: str | None = Query(
@@ -492,10 +495,6 @@ def query(
492495
None,
493496
description="Exclude a comma-separated list of batch identifiers",
494497
),
495-
batch_id_field: str = Query(
496-
"builder_meta.batch_id",
497-
description="Field name to query against for batch_id",
498-
),
499498
) -> STORE_PARAMS:
500499
# NOTE: maggma's StringQueryOperator doesn't work for nested fields?
501500
all_kwargs = [batch_id, batch_id_not_eq, batch_id_eq_any, batch_id_neq_any]
@@ -506,7 +505,7 @@ def query(
506505
)
507506

508507
crit = {} # type: dict
509-
k = batch_id_field
508+
k = self._field
510509
if batch_id:
511510
crit[k] = batch_id
512511
elif batch_id_not_eq:

emmet-api/emmet/api/routes/materials/tasks/resources.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def task_resource(task_store):
2727
task_store,
2828
TaskDoc,
2929
query_operators=[
30-
BatchIdQuery(),
30+
BatchIdQuery(field="batch_id"),
3131
FormulaQuery(),
3232
ChemsysQuery(),
3333
ElementsQuery(),

0 commit comments

Comments
 (0)