Fix common followers API

lolsob-rspec
Eugen Rochko 2016-10-30 15:08:36 +01:00
parent 53de3b66ce
commit e5c0f979cf
1 changed files with 1 additions and 1 deletions

View File

@ -125,7 +125,7 @@ class Account < ApplicationRecord
def common_followers_with(other_account) def common_followers_with(other_account)
results = Neography::Rest.new.execute_query('MATCH (a {account_id: {a_id}})-[:follows]->(b)-[:follows]->(c {account_id: {c_id}}) RETURN b.account_id', a_id: id, c_id: other_account.id) results = Neography::Rest.new.execute_query('MATCH (a {account_id: {a_id}})-[:follows]->(b)-[:follows]->(c {account_id: {c_id}}) RETURN b.account_id', a_id: id, c_id: other_account.id)
ids = results['data'].map(&:first) ids = results['data'].map(&:first)
accounts = self.where(id: ids).with_counters.map { |a| [a.id, a] }.to_h accounts = Account.where(id: ids).with_counters.map { |a| [a.id, a] }.to_h
ids.map { |id| accounts[id] }.compact ids.map { |id| accounts[id] }.compact
rescue Neography::NeographyError, Excon::Error::Socket rescue Neography::NeographyError, Excon::Error::Socket
[] []