From 64e09a1b35cc1897df7e46e73989c6e7013f6196 Mon Sep 17 00:00:00 2001 From: Grzegorz Bizon Date: Mon, 8 May 2017 12:47:21 +0200 Subject: Fix pipeline status when allowed to fail jobs present --- app/models/concerns/has_status.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'app/models') diff --git a/app/models/concerns/has_status.rb b/app/models/concerns/has_status.rb index 3c9c6584e02..692bd1f9317 100644 --- a/app/models/concerns/has_status.rb +++ b/app/models/concerns/has_status.rb @@ -37,7 +37,9 @@ module HasStatus end def status - all.pluck(status_sql).first + all.pluck(status_sql).first.tap do |status| + return 'success' if status == 'skipped' && all.failed_but_allowed.any? + end end def started_at -- cgit v1.2.3 From 21f3e9ce2617b8869583bdae60cc619bcd0a29bd Mon Sep 17 00:00:00 2001 From: Grzegorz Bizon Date: Mon, 8 May 2017 14:26:08 +0200 Subject: Move custom compound status method to commit status --- app/models/commit_status.rb | 6 ++++++ app/models/concerns/has_status.rb | 4 +--- 2 files changed, 7 insertions(+), 3 deletions(-) (limited to 'app/models') diff --git a/app/models/commit_status.rb b/app/models/commit_status.rb index 07cec63b939..500d05fd840 100644 --- a/app/models/commit_status.rb +++ b/app/models/commit_status.rb @@ -103,6 +103,12 @@ class CommitStatus < ActiveRecord::Base end end + def self.status + super.tap do |status| + return 'success' if status == 'skipped' && all.failed_but_allowed.any? + end + end + def locking_enabled? status_changed? end diff --git a/app/models/concerns/has_status.rb b/app/models/concerns/has_status.rb index 692bd1f9317..3c9c6584e02 100644 --- a/app/models/concerns/has_status.rb +++ b/app/models/concerns/has_status.rb @@ -37,9 +37,7 @@ module HasStatus end def status - all.pluck(status_sql).first.tap do |status| - return 'success' if status == 'skipped' && all.failed_but_allowed.any? - end + all.pluck(status_sql).first end def started_at -- cgit v1.2.3 From caf6b9918e3f7a79c9ffcffd1880f29422d50eb5 Mon Sep 17 00:00:00 2001 From: Grzegorz Bizon Date: Thu, 15 Jun 2017 14:43:47 +0200 Subject: Check warnings when building compound status SQL query --- app/models/commit_status.rb | 6 ------ app/models/concerns/has_status.rb | 23 +++++++++++++---------- 2 files changed, 13 insertions(+), 16 deletions(-) (limited to 'app/models') diff --git a/app/models/commit_status.rb b/app/models/commit_status.rb index 500d05fd840..07cec63b939 100644 --- a/app/models/commit_status.rb +++ b/app/models/commit_status.rb @@ -103,12 +103,6 @@ class CommitStatus < ActiveRecord::Base end end - def self.status - super.tap do |status| - return 'success' if status == 'skipped' && all.failed_but_allowed.any? - end - end - def locking_enabled? status_changed? end diff --git a/app/models/concerns/has_status.rb b/app/models/concerns/has_status.rb index 3c9c6584e02..32af5566135 100644 --- a/app/models/concerns/has_status.rb +++ b/app/models/concerns/has_status.rb @@ -11,18 +11,21 @@ module HasStatus class_methods do def status_sql - scope = respond_to?(:exclude_ignored) ? exclude_ignored : all - - builds = scope.select('count(*)').to_sql - created = scope.created.select('count(*)').to_sql - success = scope.success.select('count(*)').to_sql - manual = scope.manual.select('count(*)').to_sql - pending = scope.pending.select('count(*)').to_sql - running = scope.running.select('count(*)').to_sql - skipped = scope.skipped.select('count(*)').to_sql - canceled = scope.canceled.select('count(*)').to_sql + scope_relevant = respond_to?(:exclude_ignored) ? exclude_ignored : all + scope_warnings = respond_to?(:failed_but_allowed) ? failed_but_allowed : none + + builds = scope_relevant.select('count(*)').to_sql + created = scope_relevant.created.select('count(*)').to_sql + success = scope_relevant.success.select('count(*)').to_sql + manual = scope_relevant.manual.select('count(*)').to_sql + pending = scope_relevant.pending.select('count(*)').to_sql + running = scope_relevant.running.select('count(*)').to_sql + skipped = scope_relevant.skipped.select('count(*)').to_sql + canceled = scope_relevant.canceled.select('count(*)').to_sql + warnings = scope_warnings.select('count(*) > 0').to_sql.presence || 'false' "(CASE + WHEN (#{builds})=(#{skipped}) AND (#{warnings}) THEN 'success' WHEN (#{builds})=(#{skipped}) THEN 'skipped' WHEN (#{builds})=(#{success}) THEN 'success' WHEN (#{builds})=(#{created}) THEN 'created' -- cgit v1.2.3