Dag Run endpoints returns count total results after filtering (#11832)

This commit is contained in:
Ephraim Anierobi 2020-10-25 22:35:30 +01:00 коммит произвёл GitHub
Родитель 872b1566a1
Коммит c62a49af07
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
2 изменённых файлов: 6 добавлений и 5 удалений

Просмотреть файл

@ -131,7 +131,6 @@ def _fetch_dag_runs(
limit,
offset,
):
total_entries = query.count()
query = _apply_date_filters_to_query(
query,
end_date_gte,
@ -141,6 +140,8 @@ def _fetch_dag_runs(
start_date_gte,
start_date_lte,
)
# Count items
total_entries = query.count()
# apply offset and limit
dag_run = query.order_by(DagRun.id).offset(offset).limit(limit).all()
return dag_run, total_entries

Просмотреть файл

@ -431,7 +431,7 @@ class TestGetDagRunsPaginationFilters(TestDagRunEndpoint):
response = self.client.get(url, environ_overrides={'REMOTE_USER': "test"})
assert response.status_code == 200
assert response.json["total_entries"] == 10
assert response.json["total_entries"] == len(expected_dag_run_ids)
dag_run_ids = [dag_run["dag_run_id"] for dag_run in response.json["dag_runs"]]
assert dag_run_ids == expected_dag_run_ids
@ -482,7 +482,7 @@ class TestGetDagRunsEndDateFilters(TestDagRunEndpoint):
self._create_test_dag_run('success') # state==success, then end date is today
response = self.client.get(url, environ_overrides={'REMOTE_USER': "test"})
assert response.status_code == 200
assert response.json["total_entries"] == 2
assert response.json["total_entries"] == len(expected_dag_run_ids)
dag_run_ids = [dag_run["dag_run_id"] for dag_run in response.json["dag_runs"] if dag_run]
assert dag_run_ids == expected_dag_run_ids
@ -706,7 +706,7 @@ class TestGetDagRunBatchDateFilters(TestDagRunEndpoint):
"api/v1/dags/~/dagRuns/list", json=payload, environ_overrides={'REMOTE_USER': "test"}
)
assert response.status_code == 200
assert response.json["total_entries"] == 10
assert response.json["total_entries"] == len(expected_dag_run_ids)
dag_run_ids = [dag_run["dag_run_id"] for dag_run in response.json["dag_runs"]]
assert dag_run_ids == expected_dag_run_ids
@ -760,7 +760,7 @@ class TestGetDagRunBatchDateFilters(TestDagRunEndpoint):
"api/v1/dags/~/dagRuns/list", json=payload, environ_overrides={'REMOTE_USER': "test"}
)
assert response.status_code == 200
assert response.json["total_entries"] == 2
assert response.json["total_entries"] == len(expected_dag_run_ids)
dag_run_ids = [dag_run["dag_run_id"] for dag_run in response.json["dag_runs"] if dag_run]
assert dag_run_ids == expected_dag_run_ids