pierrejeambrun commented on code in PR #51880:
URL: https://github.com/apache/airflow/pull/51880#discussion_r2156967914
##########
airflow-core/src/airflow/api_fastapi/core_api/routes/public/task_instances.py:
##########
@@ -194,9 +196,10 @@ def get_mapped_task_instances(
error_message = f"Task id {task_id} is not mapped"
raise HTTPException(status.HTTP_404_NOT_FOUND, error_message)
- task_instance_select, total_entries = paginated_select(
- statement=query,
- filters=[
+ if state.value is not None and None in state.value:
+ filters = [state, pool, queue, executor, version_number]
+ else:
+ filters = [
Review Comment:
I don't think we should do that, plainly ignoring the filters if `none` is
in the state filtering.
What we do for the `dashboard.py` `historical_metrics` is better I think.
We coalesce the `start_date` and `end_date` for tasks that have None there
(no_status, pending, etc...)
```
task_instance_states = session.execute(
select(TaskInstance.state, func.count(TaskInstance.run_id))
.join(TaskInstance.dag_run)
.where(
func.coalesce(DagRun.start_date, current_time) >= start_date,
func.coalesce(DagRun.end_date, current_time) <=
func.coalesce(end_date, current_time),
)
.group_by(TaskInstance.state)
).all()
```
##########
airflow-core/src/airflow/api_fastapi/core_api/routes/public/task_instances.py:
##########
@@ -194,9 +196,10 @@ def get_mapped_task_instances(
error_message = f"Task id {task_id} is not mapped"
raise HTTPException(status.HTTP_404_NOT_FOUND, error_message)
- task_instance_select, total_entries = paginated_select(
- statement=query,
- filters=[
+ if state.value is not None and None in state.value:
+ filters = [state, pool, queue, executor, version_number]
+ else:
+ filters = [
Review Comment:
(Basically a task that has `None` as a start_date, will have a start_date >
now, and therefore we can still include it if the filter is < now. (same logic
but reversed for end date)
--
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]