Add cold-start follow recommendations (#15945)
This commit is contained in:
parent
ad61265268
commit
f7117646af
32 changed files with 560 additions and 26 deletions
17
app/models/account_suggestions.rb
Normal file
17
app/models/account_suggestions.rb
Normal file
|
@ -0,0 +1,17 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class AccountSuggestions
|
||||
class Suggestion < ActiveModelSerializers::Model
|
||||
attributes :account, :source
|
||||
end
|
||||
|
||||
def self.get(account, limit)
|
||||
suggestions = PotentialFriendshipTracker.get(account, limit).map { |target_account| Suggestion.new(account: target_account, source: :past_interaction) }
|
||||
suggestions.concat(FollowRecommendation.get(account, limit - suggestions.size, suggestions.map { |suggestion| suggestion.account.id }).map { |target_account| Suggestion.new(account: target_account, source: :global) }) if suggestions.size < limit
|
||||
suggestions
|
||||
end
|
||||
|
||||
def self.remove(account, target_account_id)
|
||||
PotentialFriendshipTracker.remove(account.id, target_account_id)
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue