diff options
author | Kamil Trzcinski <ayufan@ayufan.eu> | 2016-04-13 20:51:03 +0200 |
---|---|---|
committer | Kamil Trzcinski <ayufan@ayufan.eu> | 2016-04-13 20:51:11 +0200 |
commit | 2a7f7f75285e3818ac9c90b3e6c7893f4999e33e (patch) | |
tree | be3749495543084d3ccbd665c737c9450ff9f0d2 /app/models/ci | |
parent | ae24b257189be758da6b5189f3a836654fe72f7e (diff) | |
download | gitlab-ce-2a7f7f75285e3818ac9c90b3e6c7893f4999e33e.tar.gz |
Update handling of skipped status
Diffstat (limited to 'app/models/ci')
-rw-r--r-- | app/models/ci/build.rb | 2 | ||||
-rw-r--r-- | app/models/ci/commit.rb | 23 |
2 files changed, 9 insertions, 16 deletions
diff --git a/app/models/ci/build.rb b/app/models/ci/build.rb index 085ecc6951c..c0b334d3600 100644 --- a/app/models/ci/build.rb +++ b/app/models/ci/build.rb @@ -116,7 +116,7 @@ module Ci end def retried? - !self.commit.latest.include?(self) + !self.commit.statuses.latest.include?(self) end def retry diff --git a/app/models/ci/commit.rb b/app/models/ci/commit.rb index 07cd489223f..334d3c7bc45 100644 --- a/app/models/ci/commit.rb +++ b/app/models/ci/commit.rb @@ -114,16 +114,12 @@ module Ci end end - def latest - statuses.latest - end - def retried @retried ||= (statuses.order(id: :desc) - statuses.latest) end def coverage - coverage_array = latest.map(&:coverage).compact + coverage_array = statuses.latest.map(&:coverage).compact if coverage_array.size >= 1 '%.2f' % (coverage_array.reduce(:+) / coverage_array.size) end @@ -158,18 +154,15 @@ module Ci private def update_state - reload - self.status = if yaml_errors.present? - 'failed' + statuses.reload + self.status = if yaml_errors.blank? + statuses.latest.status || 'skipped' else - latest.status + 'failed' end - self.started_at = statuses.minimum(:started_at) - self.finished_at = statuses.maximum(:finished_at) - self.duration = begin - duration_array = latest.map(&:duration).compact - duration_array.reduce(:+).to_i - end + self.started_at = statuses.started_at + self.finished_at = statuses.finished_at + self.duration = statuses.latest.duration save end |