ashb commented on code in PR #37436:
URL: https://github.com/apache/airflow/pull/37436#discussion_r1699923636


##########
airflow/www/views.py:
##########
@@ -839,21 +841,92 @@ def index(self):
         with create_session() as session:
             # read orm_dags from the db
             dags_query = select(DagModel).where(~DagModel.is_subdag, 
DagModel.is_active)
-
+            dags_query = dags_query.where(DagModel.dag_id.in_(filter_dag_ids))
             if arg_search_query:
-                escaped_arg_search_query = arg_search_query.replace("_", r"\_")
-                dags_query = dags_query.where(
-                    DagModel.dag_id.ilike("%" + escaped_arg_search_query + 
"%", escape="\\")
-                    | DagModel._dag_display_property_value.ilike(
-                        "%" + escaped_arg_search_query + "%", escape="\\"
+                prefix_search_match = re2.match(r"(?i)(dag|owner|task):\s*", 
arg_search_query)
+                if prefix_search_match:
+                    query_prefix = prefix_search_match[0].lower()
+                    query_value = arg_search_query[len(query_prefix) :]
+                    if query_value:
+                        escaped_query_value = "%" + query_value.replace("_", 
r"\_") + "%"
+                        if query_prefix.startswith("task:"):
+                            if session.bind.dialect.name == "mysql":

Review Comment:
   Rather than having the database specific knowledge live in the view code 
this would make more sense if it was added as a class method on the model



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