From 49115863a20b8e3606d88b4809a5b3d0bc657500 Mon Sep 17 00:00:00 2001 From: Wout Schellaert Date: Wed, 28 Nov 2018 19:32:14 +0100 Subject: [PATCH] Update frecency formula --- app/models/user.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/models/user.rb b/app/models/user.rb index 6fd26e9..8ed1b48 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -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