uranusjr commented on code in PR #25280:
URL: https://github.com/apache/airflow/pull/25280#discussion_r938433052


##########
airflow/www/views.py:
##########
@@ -882,6 +892,18 @@ def index(self):
                 for name, in dagtags
             ]
 
+            owner_links_dict = {}
+            owner_links = session.query(DagOwnerAttributes).all()
+            # The structure we are going for is:
+            # {dag1: {owner1: link1, owner2: link2}, dag2: {owner1: link1}}
+            for owner_link_pair in owner_links:
+                owner_link_pair_dict = owner_link_pair.as_dict()
+                for dag in owner_link_pair_dict:
+                    if dag in owner_links_dict:
+                        owner_links_dict[dag].update(owner_link_pair_dict[dag])
+                    else:
+                        owner_links_dict.update(owner_link_pair_dict)

Review Comment:
   I wonder if this logic belongs to a method on `DagOwnerAttributes` instead, 
say
   
   ```python
   @classmethod
   def get_all(cls, session) -> Dict[str, Dict[str, str]]:
       dag_links = collections.defaultdict(dict)
       for obj in session.query(cls):
           dag_links[obj.dag_id].update({obj.owner: obj.link})
       return dag_links
   ```
   
   (does this also mean `as_dict` isn’t needed anymore?)



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