Commit 21136baa authored by Kamil Trzcinski's avatar Kamil Trzcinski

Update handling of skipped status

parent ed30cc04
...@@ -116,7 +116,7 @@ module Ci ...@@ -116,7 +116,7 @@ module Ci
end end
def retried? def retried?
!self.commit.latest.include?(self) !self.commit.statuses.latest.include?(self)
end end
def retry def retry
......
...@@ -125,16 +125,12 @@ module Ci ...@@ -125,16 +125,12 @@ module Ci
end end
end end
def latest
statuses.latest
end
def retried def retried
@retried ||= (statuses.order(id: :desc) - statuses.latest) @retried ||= (statuses.order(id: :desc) - statuses.latest)
end end
def coverage def coverage
coverage_array = latest.map(&:coverage).compact coverage_array = statuses.latest.map(&:coverage).compact
if coverage_array.size >= 1 if coverage_array.size >= 1
'%.2f' % (coverage_array.reduce(:+) / coverage_array.size) '%.2f' % (coverage_array.reduce(:+) / coverage_array.size)
end end
...@@ -169,18 +165,15 @@ module Ci ...@@ -169,18 +165,15 @@ module Ci
private private
def update_state def update_state
reload statuses.reload
self.status = if yaml_errors.present? self.status = if yaml_errors.blank?
'failed' statuses.latest.status || 'skipped'
else 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 end
self.started_at = statuses.started_at
self.finished_at = statuses.finished_at
self.duration = statuses.latest.duration
save save
end end
......
...@@ -15,7 +15,7 @@ module CiStatus ...@@ -15,7 +15,7 @@ module CiStatus
skipped = all.skipped.select('count(*)').to_sql skipped = all.skipped.select('count(*)').to_sql
deduce_status = "(CASE deduce_status = "(CASE
WHEN (#{builds})=0 THEN 'skipped' WHEN (#{builds})=0 THEN NULL
WHEN (#{builds})=(#{success})+(#{ignored}) THEN 'success' WHEN (#{builds})=(#{success})+(#{ignored}) THEN 'success'
WHEN (#{builds})=(#{pending}) THEN 'pending' WHEN (#{builds})=(#{pending}) THEN 'pending'
WHEN (#{builds})=(#{canceled}) THEN 'canceled' WHEN (#{builds})=(#{canceled}) THEN 'canceled'
...@@ -35,6 +35,14 @@ module CiStatus ...@@ -35,6 +35,14 @@ module CiStatus
duration_array = all.map(&:duration).compact duration_array = all.map(&:duration).compact
duration_array.reduce(:+).to_i duration_array.reduce(:+).to_i
end end
def started_at
all.minimum(:started_at)
end
def finished_at
all.minimum(:finished_at)
end
end end
included do included do
......
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