summaryrefslogtreecommitdiff
path: root/app/helpers/graph_helper.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/helpers/graph_helper.rb')
-rw-r--r--app/helpers/graph_helper.rb10
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