henry3260 commented on code in PR #68286:
URL: https://github.com/apache/airflow/pull/68286#discussion_r3386846778


##########
airflow-core/tests/unit/api_fastapi/core_api/test_security.py:
##########
@@ -55,9 +56,25 @@
 from airflow.models.dag import DagModel
 from airflow.models.team import Team
 
+from tests_common.test_utils.asserts import assert_queries_count
 from tests_common.test_utils.config import conf_vars
 
 
[email protected]_test
+def test_build_dag_run_access_requests_batches_team_lookup():
+    """The bulk dag-run team resolution must be a single query regardless of 
dag count (no N+1)."""

Review Comment:
   ```suggestion
       """The bulk dag-run team resolution must be a single query regardless of 
Dag count (no N+1)."""
   ```



##########
airflow-core/src/airflow/api_fastapi/core_api/security.py:
##########
@@ -738,10 +738,13 @@ def _build_dag_run_access_requests(
 
     ``entity_methods`` is a list of ``(dag_id, method)`` pairs with 
unresolvable
     entries (no dag_id or the ``~`` wildcard) already filtered out by the 
caller.
-    The team for each dag is resolved once and shared across that dag's 
requests.
+    Teams for all dags are resolved in a single batched query and shared 
across each
+    dag's requests.

Review Comment:
   ```suggestion
       Teams for all Dags are resolved in a single batched query and shared 
across each
       Dag's requests.
   ```



##########
airflow-core/tests/unit/api_fastapi/core_api/test_security.py:
##########
@@ -55,9 +56,25 @@
 from airflow.models.dag import DagModel
 from airflow.models.team import Team
 
+from tests_common.test_utils.asserts import assert_queries_count
 from tests_common.test_utils.config import conf_vars
 
 
[email protected]_test
+def test_build_dag_run_access_requests_batches_team_lookup():
+    """The bulk dag-run team resolution must be a single query regardless of 
dag count (no N+1)."""
+    entity_methods = [(f"dag_{i}", "GET") for i in range(25)]

Review Comment:
   Could we add a team-owned Dag and assert that the correct `team_name `is 
included in the generated access request?



-- 
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]

Reply via email to