diff options
author | Kamil Trzcinski <ayufan@ayufan.eu> | 2015-12-04 14:55:23 +0300 |
---|---|---|
committer | Kamil Trzcinski <ayufan@ayufan.eu> | 2015-12-11 20:02:09 +0300 |
commit | e80e3f5372d6bcad1fbe04a85b3086bb66794828 (patch) | |
tree | 16b1539cfd158ecac7fe05d595cbba30b8bc1a04 /app/helpers/graph_helper.rb | |
parent | 8b4cdc50fca816b4f56f8579e17c4dba836ec797 (diff) |
Migrate CI::Project to Project
Diffstat (limited to 'app/helpers/graph_helper.rb')
-rw-r--r-- | app/helpers/graph_helper.rb | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/app/helpers/graph_helper.rb b/app/helpers/graph_helper.rb index 1e372d5631d..c2ab80f2e0d 100644 --- a/app/helpers/graph_helper.rb +++ b/app/helpers/graph_helper.rb @@ -16,4 +16,14 @@ module GraphHelper ids = parents.map { |p| p.id } ids.zip(parent_spaces) end + + def success_ratio(success_builds, failed_builds) + failed_builds = failed_builds.count(:all) + success_builds = success_builds.count(:all) + + return 100 if failed_builds.zero? + + ratio = (success_builds.to_f / (success_builds + failed_builds)) * 100 + ratio.to_i + end end |