safaehar commented on code in PR #75216:
URL: https://github.com/apache/airflow/pull/75216#discussion_r4414980773


##########
airflow-core/src/airflow/api_fastapi/core_api/routes/public/pools.py:
##########
@@ -46,11 +46,32 @@
 )
 from airflow.api_fastapi.core_api.services.public.pools import 
BulkPoolService, update_orm_from_pydantic
 from airflow.api_fastapi.logging.decorators import action_logging
-from airflow.models.pool import Pool
+from airflow.models.pool import Pool, PoolStats
 
 pools_router = AirflowRouter(tags=["Pool"], prefix="/pools")
 
 
+def _build_pool_response(pool: Pool, stats: PoolStats) -> PoolResponse:
+    occupied_slots = stats["running"] + stats["queued"]
+    if pool.include_deferred:
+        occupied_slots += stats["deferred"]
+    return PoolResponse.model_validate(
+        {
+            "pool": pool.pool,
+            "slots": pool.slots,
+            "description": pool.description,
+            "include_deferred": pool.include_deferred,
+            "team_name": pool.team_name,
+            "occupied_slots": occupied_slots,
+            "running_slots": stats["running"],
+            "queued_slots": stats["queued"],
+            "scheduled_slots": stats["scheduled"],
+            "open_slots": stats["open"],

Review Comment:
   Good point. I changed it, i now derive open_slots from the pool row’s slots, 
include_deferred, and the aggregated occupied slots and i added a regression 
test simulating a capacity change between the two reads
   



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