Skip to content

Commit

Permalink
fixup_filtering
Browse files Browse the repository at this point in the history
  • Loading branch information
jedcunningham committed Feb 16, 2024
1 parent 0a95299 commit 08d2560
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
9 changes: 4 additions & 5 deletions airflow/api_connexion/endpoints/import_error_endpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,11 @@ def get_import_errors(
if not can_read_all_dags:
# if the user doesn't have access to all DAGs, only display errors from visible DAGs
readable_dag_ids = security.get_readable_dags()
query = query.join(DagModel, DagModel.fileloc == ImportErrorModel.filename).where(
DagModel.dag_id.in_(readable_dag_ids)
)
count_query = count_query.join(DagModel, DagModel.fileloc == ImportErrorModel.filename).where(
DagModel.dag_id.in_(readable_dag_ids)
dagfiles_subq = (
select(DagModel.fileloc).distinct().where(DagModel.dag_id.in_(readable_dag_ids)).subquery()
)
query = query.where(ImportErrorModel.filename.in_(dagfiles_subq))
count_query = count_query.where(ImportErrorModel.filename.in_(dagfiles_subq))

total_entries = session.scalars(count_query).one()
import_errors = session.scalars(query.offset(offset).limit(limit)).all()
Expand Down
11 changes: 8 additions & 3 deletions airflow/www/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -942,9 +942,14 @@ def index(self):
can_read_all_dags = get_auth_manager().is_authorized_dag(method="GET")
if not can_read_all_dags:
# if the user doesn't have access to all DAGs, only display errors from visible DAGs
import_errors = import_errors.join(
DagModel, DagModel.fileloc == errors.ImportError.filename
).where(DagModel.dag_id.in_(filter_dag_ids))
import_errors = import_errors.where(
errors.ImportError.filename.in_(
select(DagModel.fileloc)
.distinct()
.where(DagModel.dag_id.in_(filter_dag_ids))
.subquery()
)
)

import_errors = session.scalars(import_errors)
for import_error in import_errors:
Expand Down

0 comments on commit 08d2560

Please sign in to comment.