You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2019/11/09 13:47:08 UTC

[GitHub] [airflow] BasPH commented on a change in pull request #6489: [AIRFLOW-3959] [AIRFLOW-4026] Add filter by DAG tags

BasPH commented on a change in pull request #6489: [AIRFLOW-3959] [AIRFLOW-4026] Add filter by DAG tags
URL: https://github.com/apache/airflow/pull/6489#discussion_r344444803
 
 

 ##########
 File path: airflow/www/views.py
 ##########
 @@ -246,10 +266,20 @@ def get_int_arg(value, default=0):
                     DagModel.owners.ilike('%' + arg_search_query + '%')
                 )
 
+            if arg_tags_filter:
+                dags_query = dags_query.filter(DagModel.tags.any(DagTag.name.in_(arg_tags_filter)))
+
             if 'all_dags' not in filter_dag_ids:
                 dags_query = dags_query.filter(DagModel.dag_id.in_(filter_dag_ids))
 
             dags = dags_query.order_by(DagModel.dag_id).offset(start).limit(dags_per_page).all()
+            tags = []
+
+            for name, in session.query(DagTag.name).distinct(DagTag.name).all():
+                value = {'name': name, 'selected': False}
+                if arg_tags_filter and name in arg_tags_filter:
+                    value['selected'] = True
+                tags.append(value)
 
 Review comment:
   It's not only shorter but list comprehensions are generally also faster. Does this make it more readable for you? The `True if X else False` can also be replaced by a single `bool()` call.
   
   ```python
   dagtags = session.query(DagTag.name).distinct(DagTag.name).all()
   tags = [
       {"name": name, "selected": bool(arg_tags_filter and name in arg_tags_filter)}
       for name, in dagtags
   ]
   ```

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services