Merge pull request #115 from ZeusWPI/frecency-update

Update frecency formula
This commit is contained in:
Wout Schellaert 2018-11-28 19:48:21 +01:00 committed by GitHub
commit cda4431aac
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -46,11 +46,13 @@ class User < ActiveRecord::Base
.limit(num_orders)
.distinct
.pluck(:created_at)
self.frecency = (last_datetimes.map(&:to_time).map(&:to_i).sum / (num_orders * 10)) * self.multiplier
frequency = (last_datetimes.map(&:to_time).map(&:to_i).sum / (num_orders * 10))
bonus = self.rich_privilige / 1.936
self.frecency = frequency * bonus
self.save
end
def multiplier
def rich_privilige
Math.atan(self.balance / 10) + (Math::PI / 2)
end