You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by bb...@apache.org on 2022/03/21 14:03:20 UTC

[airflow] 01/01: Check if there are instances before adding a count

This is an automated email from the ASF dual-hosted git repository.

bbovenzi pushed a commit to branch fix-blank-mapped-graph
in repository https://gitbox.apache.org/repos/asf/airflow.git

commit 03f3dc0cd466a76404f6b5b11d41cdef3a031d87
Author: Brent Bovenzi <br...@gmail.com>
AuthorDate: Mon Mar 21 09:51:45 2022 -0400

    Check if there are instances before adding a count
---
 airflow/www/static/js/graph.js | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/airflow/www/static/js/graph.js b/airflow/www/static/js/graph.js
index 1ba99a8..85407aa 100644
--- a/airflow/www/static/js/graph.js
+++ b/airflow/www/static/js/graph.js
@@ -87,10 +87,16 @@ let innerSvg = d3.select('#graph-svg g');
 // returns true if at least one node is changed
 const updateNodeLabels = (node, instances) => {
   let haveLabelsChanged = false;
-  const label = tasks[node.id] && tasks[node.id].is_mapped
-    ? `${node.id} [${(instances[node.id].mapped_states && instances[node.id].mapped_states.length) || ' '}]`
-    : node.value.label;
-
+  let { label } = node.value;
+  // Check if there is a count of mapped instances
+  if (tasks[node.id] && tasks[node.id].is_mapped) {
+    const count = instances[node.id]
+      && instances[node.id].mapped_states
+      ? instances[node.id].mapped_states.length
+      : ' ';
+
+    label = `${node.id} [${count}]`;
+  }
   if (g.node(node.id) && g.node(node.id).label !== label) {
     g.node(node.id).label = label;
     haveLabelsChanged = true;