From d64590a534b15a2e44fe56795b2acd8972db6a3e Mon Sep 17 00:00:00 2001 From: wvengen Date: Thu, 10 Oct 2013 17:49:06 +0200 Subject: [PATCH] more robustness --- app/models/ordergroup.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/ordergroup.rb b/app/models/ordergroup.rb index 6e1b65dc..0188abcf 100644 --- a/app/models/ordergroup.rb +++ b/app/models/ordergroup.rb @@ -66,7 +66,7 @@ class Ordergroup < Group end def avg_jobs_per_euro - stats[:orders_sum] != 0 ? stats[:jobs_size].to_f / stats[:orders_sum].to_f : 0 + stats[:jobs_size].to_f / stats[:orders_sum].to_f rescue 0 end # This is the ordergroup job per euro performance @@ -90,7 +90,7 @@ class Ordergroup < Group # Global average def self.avg_jobs_per_euro stats = Ordergroup.pluck(:stats) - stats.sum {|s| s[:jobs_size].to_f } / stats.sum {|s| s[:orders_sum].to_f } + stats.sum {|s| s[:jobs_size].to_f } / stats.sum {|s| s[:orders_sum].to_f } rescue 0 end def account_updated