uranusjr commented on a change in pull request #20485:
URL: https://github.com/apache/airflow/pull/20485#discussion_r777820551
##########
File path: airflow/api_connexion/endpoints/dag_run_endpoint.py
##########
@@ -204,6 +207,10 @@ def get_dag_runs_batch(*, session: Session = NEW_SESSION)
-> APIResponse:
else:
query = query.filter(DagRun.dag_id.in_(readable_dag_ids))
+ if data.get("states"):
+ states = set(data["states"])
+ query = query.filter(DagRun.state.in_(states))
Review comment:
```suggestion
states = data.get("states")
if states:
query = query.filter(DagRun.state.in_(states))
```
Python variables are function-scoped, not block-scoped, so it’s not useful
to put the variable inside the `if` block. And moving the variable out avoids
one unnecessary member access overhead.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]