scrdest commented on a change in pull request #11652:
URL: https://github.com/apache/airflow/pull/11652#discussion_r512182055



##########
File path: airflow/www/utils.py
##########
@@ -302,6 +311,48 @@ def dag_run_link(attr):
         '<a href="{url}">{run_id}</a>').format(url=url, run_id=run_id)  # noqa
 
 
+def dag_query_for_key(sorting_key):
+    """Maps sorting key param in the URL params to DB queries on appropriate 
attributes."""
+    dag_query_key_map = {
+        'dag_id': DagModel.dag_id,
+        'owner': DagModel.owners,
+        'schedule': DagModel.next_dagrun,
+        # <- add any extra (URL param)->(DagModel attr) mappings here
+    }

Review comment:
       I see your point, but I feel like the suggested way is a bigger PITA 
from a long-term maintenance perspective - you have to add each new sortable in 
duplicate. It also seems less intuitive when looking at the URL - the current 
setup basically just replicates the underlying SQL. All in all, I was trying to 
make the two bits as independently testable as possible.
   
   I may be getting ahead of myself, but it should also make things easier if 
someone wanted to sort by multiple columns - e.g. ASC by ID and DESC by owner 
would be `orderBy=asc;desc` and then you could just `zip()` it with `sortBy`'s 
items.
   
   Re: the module location, point taken. I will move things around as 
appropriate. I was kind of hoping someone would slap me and point me to the 
right place if this one wasn't it, so - appreciated!




----------------------------------------------------------------
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:
[email protected]


Reply via email to