|
17 | 17 |
|
18 | 18 | from __future__ import annotations
|
19 | 19 |
|
20 |
| -from collections.abc import Sequence |
21 |
| -from typing import Annotated, Any, Literal, cast |
| 20 | +from typing import Annotated, Literal, cast |
22 | 21 |
|
23 | 22 | import structlog
|
24 | 23 | from fastapi import Depends, HTTPException, Query, status
|
25 |
| -from sqlalchemy import func, or_, select |
| 24 | +from sqlalchemy import or_, select |
26 | 25 | from sqlalchemy.orm import joinedload
|
27 | 26 | from sqlalchemy.sql.selectable import Select
|
28 | 27 |
|
|
50 | 49 | float_range_filter_factory,
|
51 | 50 | )
|
52 | 51 | from airflow.api_fastapi.common.router import AirflowRouter
|
53 |
| -from airflow.api_fastapi.core_api.base import OrmClause |
54 | 52 | from airflow.api_fastapi.core_api.datamodels.common import BulkBody, BulkResponse
|
55 | 53 | from airflow.api_fastapi.core_api.datamodels.task_instances import (
|
56 | 54 | BulkTaskInstanceBody,
|
@@ -196,26 +194,21 @@ def get_mapped_task_instances(
|
196 | 194 | error_message = f"Task id {task_id} is not mapped"
|
197 | 195 | raise HTTPException(status.HTTP_404_NOT_FOUND, error_message)
|
198 | 196 |
|
199 |
| - filters = [ |
200 |
| - run_after_range, |
201 |
| - logical_date_range, |
202 |
| - start_date_range, |
203 |
| - end_date_range, |
204 |
| - update_at_range, |
205 |
| - duration_range, |
206 |
| - state, |
207 |
| - pool, |
208 |
| - queue, |
209 |
| - executor, |
210 |
| - version_number, |
211 |
| - ] |
212 |
| - if state.value is not None and None in state.value: |
213 |
| - current_time = func.now() |
214 |
| - for f in (start_date_range, end_date_range): |
215 |
| - f.attribute = func.coalesce(f.attribute, current_time) |
216 | 197 | task_instance_select, total_entries = paginated_select(
|
217 | 198 | statement=query,
|
218 |
| - filters=cast("Sequence[OrmClause[Any]]", filters), |
| 199 | + filters=[ |
| 200 | + run_after_range, |
| 201 | + logical_date_range, |
| 202 | + start_date_range, |
| 203 | + end_date_range, |
| 204 | + update_at_range, |
| 205 | + duration_range, |
| 206 | + state, |
| 207 | + pool, |
| 208 | + queue, |
| 209 | + executor, |
| 210 | + version_number, |
| 211 | + ], |
219 | 212 | order_by=order_by,
|
220 | 213 | offset=offset,
|
221 | 214 | limit=limit,
|
@@ -467,26 +460,24 @@ def get_task_instances(
|
467 | 460 | )
|
468 | 461 | query = query.where(TI.run_id == dag_run_id)
|
469 | 462 |
|
470 |
| - filters = [ |
471 |
| - run_after_range, |
472 |
| - logical_date_range, |
473 |
| - start_date_range, |
474 |
| - end_date_range, |
475 |
| - update_at_range, |
476 |
| - duration_range, |
477 |
| - state, |
478 |
| - pool, |
479 |
| - queue, |
480 |
| - executor, |
481 |
| - version_number, |
482 |
| - ] |
483 |
| - if state.value is not None and None in state.value: |
484 |
| - current_time = func.now() |
485 |
| - for f in (start_date_range, end_date_range): |
486 |
| - f.attribute = func.coalesce(f.attribute, current_time) |
487 | 463 | task_instance_select, total_entries = paginated_select(
|
488 | 464 | statement=query,
|
489 |
| - filters=cast("Sequence[OrmClause[Any]]", filters), |
| 465 | + filters=[ |
| 466 | + run_after_range, |
| 467 | + logical_date_range, |
| 468 | + start_date_range, |
| 469 | + end_date_range, |
| 470 | + update_at_range, |
| 471 | + duration_range, |
| 472 | + state, |
| 473 | + pool, |
| 474 | + queue, |
| 475 | + executor, |
| 476 | + task_id, |
| 477 | + task_display_name_pattern, |
| 478 | + version_number, |
| 479 | + readable_ti_filter, |
| 480 | + ], |
490 | 481 | order_by=order_by,
|
491 | 482 | offset=offset,
|
492 | 483 | limit=limit,
|
|
0 commit comments