app/models/stats.rb in mumuki-laboratory-5.7.0 vs app/models/stats.rb in mumuki-laboratory-5.8.0
- old
+ new
@@ -1,49 +1,24 @@
class Stats
include ActiveModel::Model
- attr_accessor :passed, :passed_with_warnings, :failed, :unknown
+ attr_accessor :passed, :passed_with_warnings, :failed, :pending
- def total
- submitted + unknown
- end
-
def submitted
- failed + resolved
+ passed + passed_with_warnings + failed
end
- def pending
- failed + unknown
- end
-
- def resolved
- passed + passed_with_warnings
- end
-
def done?
- pending == 0
+ failed + pending == 0
end
def started?
submitted > 0
end
- def to_h(&key)
- {key.call(:passed) => passed,
- key.call(:passed_with_warnings) => passed_with_warnings,
- key.call(:failed) => failed,
- key.call(:unknown) => unknown}
- end
-
def self.from_statuses(statuses)
- Stats.new(statuses.inject({passed: 0, passed_with_warnings: 0, failed: 0, unknown: 0}) do |accum, status|
+ Stats.new(statuses.inject({passed: 0, passed_with_warnings: 0, failed: 0, pending: 0}) do |accum, status|
accum[status.group.to_sym] += 1
accum
end)
- end
-
- private
-
- def ratio(x)
- (100 * x / total.to_f).round(2)
end
end