about summary refs log tree commit diff
path: root/app/models/follow_suggestion.rb
blob: f4515700abba9d3593cf6b4f6c347cde95ea2014 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
class FollowSuggestion
  def self.get(for_account_id)
    neo = Neography::Rest.new
    account_ids = neo.execute_query('START a=node:account_index(Account={id}) MATCH (a)-[:follows]->(b)-[:follows]->(c) WHERE a <> c AND NOT (a)-[:follows]->(c) RETURN DISTINCT c.account_id', id: for_account_id)
    Account.where(id: account_ids['data'].first) unless account_ids.empty?
  rescue Neography::NeographyError, Excon::Error::Socket => e
    Rails.logger.error e
    []
  end
end