Merge pull request #113 from ZeusWPI/feature/frecendebt

frecendebt
This commit is contained in:
Rien 2018-10-23 21:27:49 +02:00 committed by GitHub
commit a3e894574c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -46,10 +46,14 @@ class User < ActiveRecord::Base
.limit(num_orders) .limit(num_orders)
.distinct .distinct
.pluck(:created_at) .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 self.save
end end
def multiplier
Math.atan(self.balance / 10) + (Math::PI / 2)
end
def balance def balance
@balance || begin @balance || begin
if Rails.env.test? if Rails.env.test?