diff options
author | Z.J. van de Weg <git@zjvandeweg.nl> | 2017-06-22 15:37:59 +0300 |
---|---|---|
committer | Z.J. van de Weg <git@zjvandeweg.nl> | 2017-06-23 12:46:55 +0300 |
commit | 13d39971f33e4064bd5c8da1865cc874e1005e52 (patch) | |
tree | 8f4563162e928b52eb638e7d9e3e0987c53a5115 /app/helpers/graph_helper.rb | |
parent | 9c7bf123564ee3c045c2aa3625f8a691f91a23aa (diff) |
Improve performance for pipeline charts
Achieved by using another table, which both has better indexes and
is smaller. Now the data provided for the user is more valueable too.
Diffstat (limited to 'app/helpers/graph_helper.rb')
-rw-r--r-- | app/helpers/graph_helper.rb | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/app/helpers/graph_helper.rb b/app/helpers/graph_helper.rb index c2ab80f2e0d..bb7bdd82281 100644 --- a/app/helpers/graph_helper.rb +++ b/app/helpers/graph_helper.rb @@ -17,13 +17,10 @@ module GraphHelper ids.zip(parent_spaces) end - def success_ratio(success_builds, failed_builds) - failed_builds = failed_builds.count(:all) - success_builds = success_builds.count(:all) + def success_ratio(success:, failed:) + return 100 if failed.zero? - return 100 if failed_builds.zero? - - ratio = (success_builds.to_f / (success_builds + failed_builds)) * 100 + ratio = (success.to_f / (success + failed)) * 100 ratio.to_i end end |