villebro commented on a change in pull request #13122:
URL: https://github.com/apache/superset/pull/13122#discussion_r579430885



##########
File path: superset-frontend/src/visualizations/TimeTable/TimeTable.jsx
##########
@@ -209,10 +209,20 @@ const TimeTable = ({
             .reduce((a, b) => a + b);
       } else if (column.colType === 'avg') {
         // Average over the last {timeLag}
-        v =
-          reversedEntries
-            .map((k, i) => (i < column.timeLag ? k[valueField] : 0))
-            .reduce((a, b) => a + b) / column.timeLag;
+        v = null;
+        if (reversedEntries.length > 0) {
+          const stats = reversedEntries.slice(undefined, 
column.timeLag).reduce(
+            function ({ count, sum }, entry) {
+              return entry[valueField] != null

Review comment:
       @pavlozt if this extra check has a significant performance impact then 
I'm ok leaving it out. But I would be surprised if that's the case. The reason 
I was hoping to add broader checking is because many of these legacy plugins 
lack proper type declarations, hence it makes sense to do extra checking when 
unsure what the types may be.




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



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to