]> cat aescling's git repositories - mastodon.git/commitdiff
Fix multiple results return from FollowSuggestion.get
authorEugen Rochko <eugen@zeonfederated.com>
Sat, 15 Oct 2016 10:58:34 +0000 (12:58 +0200)
committerEugen Rochko <eugen@zeonfederated.com>
Sat, 15 Oct 2016 11:00:21 +0000 (13:00 +0200)
app/models/follow_suggestion.rb

index f4515700abba9d3593cf6b4f6c347cde95ea2014..c14dba6725c7df06d50052620f4bac3c49226873 100644 (file)
@@ -1,8 +1,8 @@
 class FollowSuggestion
-  def self.get(for_account_id)
+  def self.get(for_account_id, limit = 6)
     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?
+    Account.where(id: account_ids['data'].map(&:first)).limit(limit) unless account_ids.empty?
   rescue Neography::NeographyError, Excon::Error::Socket => e
     Rails.logger.error e
     []