mariana-marcal-santana commented on code in PR #51264:
URL: https://github.com/apache/airflow/pull/51264#discussion_r2134858171


##########
airflow-core/src/airflow/api_fastapi/core_api/routes/public/dags.py:
##########
@@ -54,23 +54,45 @@
 from airflow.api_fastapi.core_api.datamodels.dags import (
     DAGCollectionResponse,
     DAGDetailsResponse,
+    DAGFavoriteBody,
     DAGPatchBody,
     DAGResponse,
 )
 from airflow.api_fastapi.core_api.openapi.exceptions import 
create_openapi_http_exception_doc
 from airflow.api_fastapi.core_api.security import (
     EditableDagsFilterDep,
+    GetUserDep,
     ReadableDagsFilterDep,
     requires_access_dag,
 )
 from airflow.api_fastapi.logging.decorators import action_logging
 from airflow.exceptions import AirflowException, DagNotFound
 from airflow.models import DAG, DagModel
+from airflow.models.dag_favorite import DagFavorite
 from airflow.models.dagrun import DagRun
 
 dags_router = AirflowRouter(tags=["DAG"], prefix="/dags")
 
 
+@dags_router.get("/favorite", 
dependencies=[Depends(requires_access_dag(method="GET"))])
+def get_favorite_dags(session: SessionDep, user: GetUserDep) -> 
DAGCollectionResponse:
+    """Get DAGs favorited by the user."""
+    user_id = user.get_id()
+
+    favorite_dags_query = (
+        select(DagModel)
+        .join(DagFavorite, DagModel.dag_id == DagFavorite.dag_id)
+        .where(DagFavorite.user_id == user_id)
+    )
+
+    dags = session.scalars(favorite_dags_query).all()
+
+    return DAGCollectionResponse(
+        dags=dags,
+        total_entries=len(dags),
+    )

Review Comment:
   > I think we are missing filtering the dag_id by the `readable_dag_ids`
   
   Since this endpoint has been merged in the GetDags endpoint, we believe this 
has been fixed.
   Thank you



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