UI: Fix gant chart on buildset page for missing timestamps

Currently, the "Builds Timeline" gant chart on the buildset result page
is broken when at least one build doesn't provide the required time
information (e.g. SKIPPED builds).

  index.js:1 Warning: Received NaN for the `x1` attribute. If this is
  expected, cast the value to a string.
      in line (created by Line)
      in Line
      in LineSegment
      in g
      in g
      in VictoryAxis (created by ChartAxis)
      in ChartAxis (at GanttChart.jsx:88)
      ...

To fix this, we fill the missing timestamp information with 0 values.

Change-Id: I3ec6a36a3cfcf818127b827543fd7b8ecf5d785a
This commit is contained in:
Felix Edel
2021-10-20 09:38:32 +02:00
parent 55242af7cb
commit fa8e1a7c95
+2 -2
View File
@@ -43,8 +43,8 @@ function BuildsetGanttChart(props) {
const data = sortedByStartTime.map((build) => {
return {
x: build.job_name,
y0: (moment.utc(build.start_time).tz(timezone) - origin) / 1000,
y: (moment.utc(build.end_time).tz(timezone) - origin) / 1000,
y0: build.start_time ? (moment.utc(build.start_time).tz(timezone) - origin) / 1000 : 0,
y: build.end_time ? (moment.utc(build.end_time).tz(timezone) - origin) / 1000 : 0,
result: build.result,
started: moment.utc(build.start_time).tz(timezone).format('YYYY-MM-DD HH:mm:ss'),
ended: moment.utc(build.end_time).tz(timezone).format('YYYY-MM-DD HH:mm:ss'),