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