Commit 33bbfd27 authored by Lin Jen-Shin's avatar Lin Jen-Shin

on_failure should also be ignored, and status_sql should

also respect this ignorance. Address feedback from:
https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/6604#note_16273363
parent dd01f3a7
...@@ -8,7 +8,7 @@ module HasStatus ...@@ -8,7 +8,7 @@ module HasStatus
class_methods do class_methods do
def status_sql def status_sql
scope = all scope = exclude_ignored_jobs
builds = scope.select('count(*)').to_sql builds = scope.select('count(*)').to_sql
created = scope.created.select('count(*)').to_sql created = scope.created.select('count(*)').to_sql
success = scope.success.select('count(*)').to_sql success = scope.success.select('count(*)').to_sql
...@@ -21,8 +21,8 @@ module HasStatus ...@@ -21,8 +21,8 @@ module HasStatus
deduce_status = "(CASE deduce_status = "(CASE
WHEN (#{builds})=(#{created}) THEN 'created' WHEN (#{builds})=(#{created}) THEN 'created'
WHEN (#{builds})=(#{skipped}) THEN 'skipped' WHEN (#{builds})=(#{success})+(#{ignored}) THEN 'success'
WHEN (#{builds})=(#{success})+(#{ignored})+(#{skipped}) THEN 'success' WHEN (#{builds})=(#{success})+(#{ignored})+(#{skipped}) THEN 'skipped'
WHEN (#{builds})=(#{created})+(#{pending})+(#{skipped}) THEN 'pending' WHEN (#{builds})=(#{created})+(#{pending})+(#{skipped}) THEN 'pending'
WHEN (#{builds})=(#{canceled})+(#{success})+(#{ignored})+(#{skipped}) THEN 'canceled' WHEN (#{builds})=(#{canceled})+(#{success})+(#{ignored})+(#{skipped}) THEN 'canceled'
WHEN (#{running})+(#{pending})+(#{created})>0 THEN 'running' WHEN (#{running})+(#{pending})+(#{created})>0 THEN 'running'
...@@ -68,6 +68,12 @@ module HasStatus ...@@ -68,6 +68,12 @@ module HasStatus
scope :skipped, -> { where(status: 'skipped') } scope :skipped, -> { where(status: 'skipped') }
scope :running_or_pending, -> { where(status: [:running, :pending]) } scope :running_or_pending, -> { where(status: [:running, :pending]) }
scope :finished, -> { where(status: [:success, :failed, :canceled]) } scope :finished, -> { where(status: [:success, :failed, :canceled]) }
scope :exclude_ignored_jobs, -> do
quoted_when = connection.quote_column_name('when')
# We want to ignore skipped manual jobs
where("#{quoted_when} <> ? OR status <> ?", 'manual', 'skipped').
where("#{quoted_when} <> ? OR status <> ?", 'on_failure', 'skipped')
end
end end
def started? def started?
......
...@@ -61,11 +61,7 @@ module Ci ...@@ -61,11 +61,7 @@ module Ci
end end
def status_for_prior_stages(index) def status_for_prior_stages(index)
quoted_when = pipeline.builds.connection.quote_column_name('when') pipeline.builds.exclude_ignored_jobs.where('stage_idx < ?', index).
pipeline.builds.
where('stage_idx < ?', index).
# We want to ignore skipped manual jobs
where("#{quoted_when} <> ? OR status <> ?", 'manual', 'skipped').
latest.status || 'success' latest.status || 'success'
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment