diff options
author | Kamil Trzciński <ayufan@ayufan.eu> | 2019-08-14 15:55:56 +0200 |
---|---|---|
committer | Kamil Trzciński <ayufan@ayufan.eu> | 2019-08-14 15:55:56 +0200 |
commit | 61ef7939713903ebb1bbd4f59d9b3babbde7dabd (patch) | |
tree | 5a5d418f8a0fd3f79beb27df400cb149745a266c | |
parent | d03bb35528c773684d59abdc3cb48f33ba3414c0 (diff) | |
download | gitlab-ce-ruby-composite-status-remove-status.tar.gz |
Remove HasStatus.statusruby-composite-status-remove-status
-rw-r--r-- | app/models/ci/pipeline.rb | 4 | ||||
-rw-r--r-- | app/models/ci/stage.rb | 8 | ||||
-rw-r--r-- | app/models/concerns/has_status.rb | 6 | ||||
-rw-r--r-- | app/services/ci/process_pipeline_service.rb | 8 |
4 files changed, 16 insertions, 10 deletions
diff --git a/app/models/ci/pipeline.rb b/app/models/ci/pipeline.rb index ab1f0641eb6..b04a8b089a9 100644 --- a/app/models/ci/pipeline.rb +++ b/app/models/ci/pipeline.rb @@ -843,7 +843,9 @@ module Ci def latest_builds_status return 'failed' unless yaml_errors.blank? - statuses.latest.status || 'skipped' + Gitlab::Ci::Status::GroupedStatuses + .new(statuses.latest) + .one[:status] || 'skipped' end def keep_around_commits diff --git a/app/models/ci/stage.rb b/app/models/ci/stage.rb index d90339d90dc..a52a3fb65ef 100644 --- a/app/models/ci/stage.rb +++ b/app/models/ci/stage.rb @@ -78,7 +78,7 @@ module Ci def update_status retry_optimistic_lock(self) do - case statuses.latest.status + case latest_stage_status when 'created' then nil when 'preparing' then prepare when 'pending' then enqueue @@ -124,5 +124,11 @@ module Ci def manual_playable? blocked? || skipped? end + + def latest_stage_status + Gitlab::Ci::Status::GroupedStatuses + .new(statuses.latest) + .one[:status] || 'skipped' + end end end diff --git a/app/models/concerns/has_status.rb b/app/models/concerns/has_status.rb index 60a6afbee79..ca6b412e742 100644 --- a/app/models/concerns/has_status.rb +++ b/app/models/concerns/has_status.rb @@ -18,12 +18,6 @@ module HasStatus UnknownStatusError = Class.new(StandardError) class_methods do - def status - Gitlab::Ci::Status::GroupedStatuses - .new(all) - .one[:status] - end - def started_at all.minimum(:started_at) end diff --git a/app/services/ci/process_pipeline_service.rb b/app/services/ci/process_pipeline_service.rb index f7db9ec6a55..ec5c1ee6d2d 100644 --- a/app/services/ci/process_pipeline_service.rb +++ b/app/services/ci/process_pipeline_service.rb @@ -74,13 +74,17 @@ module Ci # rubocop: disable CodeReuse/ActiveRecord def status_for_prior_stages(index) - pipeline.processables.where('stage_idx < ?', index).latest.status || 'success' + Gitlab::Ci::Status::GroupedStatuses + .new(pipeline.processables.where('stage_idx < ?', index).latest) + .one[:status] || 'success' end # rubocop: enable CodeReuse/ActiveRecord # rubocop: disable CodeReuse/ActiveRecord def status_for_build_needs(needs) - pipeline.processables.where(name: needs).latest.status || 'success' + Gitlab::Ci::Status::GroupedStatuses + .new(pipeline.processables.where(name: needs).latest) + .one[:status] || 'success' end # rubocop: enable CodeReuse/ActiveRecord |