From 6a3e4d470399ed6f2c1989cae864d346f333e9d7 Mon Sep 17 00:00:00 2001 From: i Date: Fri, 23 Mar 2012 09:34:57 -0600 Subject: [PATCH] package ratings should take into account number of users and their ratings --- app/models/package_rating.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/models/package_rating.rb b/app/models/package_rating.rb index cf0a948..d406654 100644 --- a/app/models/package_rating.rb +++ b/app/models/package_rating.rb @@ -42,6 +42,11 @@ def self.calculate_average(package_id, aspect=nil) package_id]).to_f end end + + #Package ratings should take into account number of users and their ratings + def self.calculate_rating(package_id, aspect=nil) + self.sum(sqrt('rating'*count('users'))).to_f + end def to_s rating.to_s