Skip to content

Commit

Permalink
map suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
jtomchak committed Nov 3, 2023
1 parent 22240c8 commit c4cce02
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions app/services/follow_recommendations_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def call(handle:, limit: DEFAULT_FOLLOW_LIMIT, force: false)
Rails.cache.fetch(cache_key, expires_in: 6.months, force: force) do
direct_follows = account_follows(@handle).map(&:symbolize_keys)
if direct_follows.empty?
Rails.logger.info("No follows found for #{@handle}, defaulting to `DEFAULT_FOLLOW_LIST`")
Rails.logger.info("No follows found for #{@handle}, defaulting to `SUGGESTIONS API V2`")
generate_default_follows.map(&:symbolize_keys)
end
direct_follow_ids = Set.new(direct_follows.pluck(:acct))
Expand Down Expand Up @@ -82,21 +82,15 @@ def build_follow_graph(indirect_follows, direct_follow_ids)
indirect_follow_map
end

def generate_default_follows
suggestions
end

# Returns an array of default follows in the same JSON format as the public API using AccountSerializer
# Returns an array of default follows from V2 Suggestions API
def generate_default_follows
account = account_from_handle
AccountSuggestions.get(account, limit_param(80)).map(&:account).pluck(:acct)
AccountSuggestions.get(account, MAX_RESULTS).map { |suggest| suggest.account.acct }
end

def account_from_handle
username, domain = @handle.split('@')

domain = nil if domain == Rails.configuration.x.local_domain

Account.where(username: username, domain: domain).first
end

Expand Down

0 comments on commit c4cce02

Please sign in to comment.