diff options
author | Robert Speicher <robert@gitlab.com> | 2016-05-23 16:55:59 +0000 |
---|---|---|
committer | Robert Speicher <robert@gitlab.com> | 2016-05-23 16:55:59 +0000 |
commit | bc806831e818b6e1ec2d1ae81221126f03c01f11 (patch) | |
tree | 71a1c281707c572f319eb91d3d6ec0fbbe4983a6 | |
parent | cc7f3848c59c5b677811ca074dc766308a20980b (diff) | |
parent | 9bb0d0b4079bc88134399f175ce9631005044060 (diff) | |
download | gitlab-ce-bc806831e818b6e1ec2d1ae81221126f03c01f11.tar.gz |
Merge branch 'fix-ci-charts-error-500' into 'master'
Fix Error 500 in CI charts by gracefully handling commits with no durations
## What does this MR do?
In the CI charts, this MR reports the duration of a commit to 0 if it is `nil`.
## Are there points in the code the reviewer needs to double check?
Should we omit this commit from the chart or set it to some other value?
## Why was this MR needed?
We were getting an Error 500 here: https://gitlab.com/gitlab-org/gitlab-ce/graphs/master/ci
## What are the relevant issue numbers?
#17730
See merge request !4245
-rw-r--r-- | CHANGELOG | 1 | ||||
-rw-r--r-- | lib/ci/charts.rb | 3 | ||||
-rw-r--r-- | spec/lib/ci/charts_spec.rb | 7 |
3 files changed, 10 insertions, 1 deletions
diff --git a/CHANGELOG b/CHANGELOG index 3e459f8b2ba..9fa1e1cada3 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -2,6 +2,7 @@ Please view this file on the master branch, on stable branches it's out of date. v 8.8.2 (unreleased) - Fix Error 500 when accessing application settings due to nil disabled OAuth sign-in sources + - Fix Error 500 in CI charts by gracefully handling commits with no durations v 8.8.1 - Add documentation for the "Health Check" feature diff --git a/lib/ci/charts.rb b/lib/ci/charts.rb index d53bdcbd0f2..e1636636934 100644 --- a/lib/ci/charts.rb +++ b/lib/ci/charts.rb @@ -64,7 +64,8 @@ module Ci commits.each do |commit| @labels << commit.short_sha - @build_times << (commit.duration / 60) + duration = commit.duration || 0 + @build_times << (duration / 60) end end end diff --git a/spec/lib/ci/charts_spec.rb b/spec/lib/ci/charts_spec.rb index 50a77308cde..9d1215a5760 100644 --- a/spec/lib/ci/charts_spec.rb +++ b/spec/lib/ci/charts_spec.rb @@ -12,5 +12,12 @@ describe Ci::Charts, lib: true do chart = Ci::Charts::BuildTime.new(@commit.project) expect(chart.build_times).to eq([2]) end + + it 'should handle nil build times' do + create(:ci_commit, duration: nil, project: @commit.project) + + chart = Ci::Charts::BuildTime.new(@commit.project) + expect(chart.build_times).to eq([2, 0]) + end end end |