ashb commented on a change in pull request #21740:
URL: https://github.com/apache/airflow/pull/21740#discussion_r813103315



##########
File path: airflow/www/utils.py
##########
@@ -53,10 +56,82 @@ def datetime_to_string(value: Optional[DateTime]) -> 
Optional[str]:
     return value.isoformat()
 
 
-def encode_ti(task_instance: Optional[models.TaskInstance]) -> 
Optional[Dict[str, Any]]:
+def get_mapped_instances(task_instance, session):
+    return (
+        session.query(TaskInstance)
+        .filter(
+            TaskInstance.dag_id == task_instance.dag_id,
+            TaskInstance.run_id == task_instance.run_id,
+            TaskInstance.task_id == task_instance.task_id,
+            TaskInstance.map_index >= 0,
+        )
+        .all()
+    )
+
+
+def get_instance_with_map(task_instance, session):
+    if task_instance.map_index == -1:
+        return alchemy_to_dict(task_instance)
+    mapped_instances = get_mapped_instances(task_instance, session)
+    return get_mapped_summary(task_instance, mapped_instances)
+
+
+def get_mapped_summary(parent_instance, task_instances):
+    priority = [
+        'failed',
+        'upstream_failed',
+        'up_for_retry',
+        'up_for_reschedule',
+        'queued',
+        'scheduled',
+        'deferred',
+        'sensing',
+        'running',
+        'shutdown',
+        'restarting',
+        'removed',
+        'no_status',
+        'success',
+        'skipped',
+    ]

Review comment:
       These should probably be TaskInstanceState.FAILED etc.
   
   (which when treated like strings will give you the same value you have, with 
the exception of None/"no_status".




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