oferze commented on a change in pull request #4304: [AIRFLOW-3500] Make task 
duration display user friendly
URL: https://github.com/apache/incubator-airflow/pull/4304#discussion_r240642454
 
 

 ##########
 File path: airflow/www/templates/airflow/graph.html
 ##########
 @@ -282,13 +282,21 @@
               tt += "Operator: " + task.task_type + "<br>";
               tt += "Started: " + ti.start_date + "<br>";
               tt += "Ended: " + ti.end_date + "<br>";
-              tt += "Duration: " + ti.duration + "<br>";
+              tt += "Duration: " + secondsToString(ti.duration) + "<br>";
               tt += "State: " + ti.state + "<br>";
               return tt;
             });
         });
     }
 
+    function secondsToString(seconds) {
+        var numdays = Math.floor((seconds % 31536000) / 86400); 
+        var numhours = Math.floor(((seconds % 31536000) % 86400) / 3600);
+        var numminutes = Math.floor((((seconds % 31536000) % 86400) % 3600) / 
60);
+        var numseconds = Math.floor((((seconds % 31536000) % 86400) % 3600) % 
60);
+        return (numdays > 0 ? numdays + " days " : "") + (numhours > 0 ? 
numhours + " hours " : "") + (numminutes > 0 ? numminutes + " minutes " : "") + 
(numseconds > 0 ? numseconds + " seconds" : "");
 
 Review comment:
   Fixed: 
https://github.com/apache/incubator-airflow/pull/4304/commits/63f57e438002ad41ebe49a301e125e8956c2d304

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to