Skip to content

Commit 34dec40

Browse files
Add number of queries guard for ui backfill (#57820)
1 parent e67b211 commit 34dec40

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

airflow-core/src/airflow/api_fastapi/core_api/routes/ui/backfills.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
from fastapi import Depends, status
2222
from sqlalchemy import select
23+
from sqlalchemy.orm import joinedload
2324

2425
from airflow.api_fastapi.common.db.common import SessionDep, paginated_select
2526
from airflow.api_fastapi.common.parameters import (
@@ -64,7 +65,7 @@ def list_backfills_ui(
6465
],
6566
) -> BackfillCollectionResponse:
6667
select_stmt, total_entries = paginated_select(
67-
statement=select(Backfill),
68+
statement=select(Backfill).options(joinedload(Backfill.dag_model)),
6869
filters=[dag_id, active],
6970
order_by=order_by,
7071
offset=offset,

airflow-core/tests/unit/api_fastapi/core_api/routes/ui/test_backfills.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
from airflow.models.backfill import Backfill
2626
from airflow.utils.session import provide_session
2727

28+
from tests_common.test_utils.asserts import assert_queries_count
2829
from tests_common.test_utils.db import (
2930
clear_db_backfills,
3031
clear_db_dag_bundles,
@@ -152,7 +153,8 @@ def test_should_response_200(
152153
expected_response = []
153154
for backfill in response_params:
154155
expected_response.append(backfill_responses[backfill])
155-
response = test_client.get("/backfills", params=test_params)
156+
with assert_queries_count(2):
157+
response = test_client.get("/backfills", params=test_params)
156158
assert response.status_code == 200
157159
assert response.json() == {
158160
"backfills": expected_response,

0 commit comments

Comments
 (0)