PNL0 commented on code in PR #51264:
URL: https://github.com/apache/airflow/pull/51264#discussion_r2167378597


##########
airflow-core/src/airflow/api_fastapi/common/parameters.py:
##########
@@ -112,6 +114,35 @@ def depends(cls, offset: NonNegativeInt = 0) -> 
OffsetFilter:
         return cls().set_value(offset)
 
 
+class _FavoriteFilter(BaseParam[bool]):
+    """Filter DAGs by favorite status."""
+
+    user_id: str
+
+    def to_orm(self, select_stmt: Select) -> Select:
+        if self.value is None and self.skip_none:
+            return select_stmt
+
+        if self.value:
+            select_stmt = select_stmt.join(DagFavorite, DagFavorite.dag_id == 
DagModel.dag_id).where(
+                DagFavorite.user_id == self.user_id
+            )
+        else:
+            select_stmt = select_stmt.where(
+                ~select(DagFavorite)
+                .where((DagFavorite.dag_id == DagModel.dag_id) & 
(DagFavorite.user_id == self.user_id))
+                .exists()
+            )

Review Comment:
   Done.



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