Change algorithm of follow recommendations (#28314)
Co-authored-by: Claire <claire.github-309c@sitedethib.com>
This commit is contained in:
parent
b7bdcd4f39
commit
b5ac61b2c5
35 changed files with 297 additions and 292 deletions
|
@ -1,31 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class PotentialFriendshipTracker
|
||||
EXPIRE_AFTER = 90.days.seconds
|
||||
MAX_ITEMS = 80
|
||||
|
||||
WEIGHTS = {
|
||||
reply: 1,
|
||||
favourite: 10,
|
||||
reblog: 20,
|
||||
}.freeze
|
||||
|
||||
class << self
|
||||
include Redisable
|
||||
|
||||
def record(account_id, target_account_id, action)
|
||||
return if account_id == target_account_id
|
||||
|
||||
key = "interactions:#{account_id}"
|
||||
weight = WEIGHTS[action]
|
||||
|
||||
redis.zincrby(key, weight, target_account_id)
|
||||
redis.zremrangebyrank(key, 0, -MAX_ITEMS)
|
||||
redis.expire(key, EXPIRE_AFTER)
|
||||
end
|
||||
|
||||
def remove(account_id, target_account_id)
|
||||
redis.zrem("interactions:#{account_id}", target_account_id)
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue