frecendebt

This commit is contained in:
hannes 2018-10-23 20:47:30 +02:00
parent 019301e819
commit 8a0f45002a
1 changed files with 5 additions and 1 deletions

View File

@ -46,9 +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.frecency = (last_datetimes.map(&:to_time).map(&:to_i).sum / (num_orders * 10)) * self.multiplier
self.save
end
def multiplier
Math.atan(self.balance / 10) + (Math::PI / 2)
end
def balance
@balance || begin