From 4e06818d330b4f15f334561500d506f0d24b9dfe Mon Sep 17 00:00:00 2001 From: Kamil Trzcinski Date: Thu, 10 Nov 2016 15:32:23 +0100 Subject: Support pipelines API Pass `updated_at` to get only incremental changes since last update --- app/models/commit_status.rb | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) (limited to 'app/models/commit_status.rb') diff --git a/app/models/commit_status.rb b/app/models/commit_status.rb index c345bf293c9..d9021a38ce3 100644 --- a/app/models/commit_status.rb +++ b/app/models/commit_status.rb @@ -119,16 +119,7 @@ class CommitStatus < ActiveRecord::Base def self.stages # We group by stage name, but order stages by theirs' index - unscoped.from(all, :sg).group('stage').order('max(stage_idx)', 'stage').pluck('sg.stage') - end - - def self.stages_status - # We execute subquery for each stage to calculate a stage status - statuses = unscoped.from(all, :sg).group('stage').pluck('sg.stage', all.where('stage=sg.stage').status_sql) - statuses.inject({}) do |h, k| - h[k.first] = k.last - h - end + unscoped.from(all, :sg).group('stage').order('max(stage_idx)', 'stage').select('sg.stage') end def failed_but_allowed? -- cgit v1.2.1 From d865aedafc2282f898b4bd2fdfd3660c47203c37 Mon Sep 17 00:00:00 2001 From: Kamil Trzcinski Date: Mon, 5 Dec 2016 14:17:42 +0100 Subject: Introduce `Ci::Stage`, right now this is artificial object that is build dynamically. --- app/models/commit_status.rb | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) (limited to 'app/models/commit_status.rb') diff --git a/app/models/commit_status.rb b/app/models/commit_status.rb index d9021a38ce3..2a537dc2a13 100644 --- a/app/models/commit_status.rb +++ b/app/models/commit_status.rb @@ -41,8 +41,8 @@ class CommitStatus < ActiveRecord::Base where("#{quoted_when} <> ? OR status <> ?", 'on_failure', 'skipped') end - scope :latest_ci_stages, -> { latest.ordered.includes(project: :namespace) } - scope :retried_ci_stages, -> { retried.ordered.includes(project: :namespace) } + scope :latest_ordered, -> { latest.ordered.includes(project: :namespace) } + scope :retried_ordered, -> { retried.ordered.includes(project: :namespace) } state_machine :status do event :enqueue do @@ -117,11 +117,6 @@ class CommitStatus < ActiveRecord::Base name.gsub(/\d+[\s:\/\\]+\d+\s*/, '').strip end - def self.stages - # We group by stage name, but order stages by theirs' index - unscoped.from(all, :sg).group('stage').order('max(stage_idx)', 'stage').select('sg.stage') - end - def failed_but_allowed? allow_failure? && (failed? || canceled?) end -- cgit v1.2.1 From 260d754ca89c14297e0e360d35d7914d57e290bf Mon Sep 17 00:00:00 2001 From: Kamil Trzcinski Date: Mon, 5 Dec 2016 17:52:50 +0100 Subject: Fix handling of allowed to failure jobs --- app/models/commit_status.rb | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) (limited to 'app/models/commit_status.rb') diff --git a/app/models/commit_status.rb b/app/models/commit_status.rb index 2a537dc2a13..cf90475f4d4 100644 --- a/app/models/commit_status.rb +++ b/app/models/commit_status.rb @@ -31,14 +31,9 @@ class CommitStatus < ActiveRecord::Base end scope :exclude_ignored, -> do - quoted_when = connection.quote_column_name('when') # We want to ignore failed_but_allowed jobs where("allow_failure = ? OR status IN (?)", - false, all_state_names - [:failed, :canceled]). - # We want to ignore skipped manual jobs - where("#{quoted_when} <> ? OR status <> ?", 'manual', 'skipped'). - # We want to ignore skipped on_failure - where("#{quoted_when} <> ? OR status <> ?", 'on_failure', 'skipped') + false, all_state_names - [:failed, :canceled]) end scope :latest_ordered, -> { latest.ordered.includes(project: :namespace) } -- cgit v1.2.1