about summary refs log tree commit diff
path: root/app/models/follow_suggestion.rb
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2016-10-28 20:35:30 +0200
committerEugen Rochko <eugen@zeonfederated.com>2016-10-28 20:35:30 +0200
commitc913bdfc98baab25a78866d5d2b0f0c33e017afa (patch)
tree827c3da6a6a570eff976234ef704b72939299602 /app/models/follow_suggestion.rb
parentbfb6cc5f2c792852cdbc74bc9634289a4298c1b8 (diff)
Fix follow suggestion fallback to exclude already followed users
Diffstat (limited to 'app/models/follow_suggestion.rb')
-rw-r--r--app/models/follow_suggestion.rb8
1 files changed, 5 insertions, 3 deletions
diff --git a/app/models/follow_suggestion.rb b/app/models/follow_suggestion.rb
index 146e515a0..15f3b6156 100644
--- a/app/models/follow_suggestion.rb
+++ b/app/models/follow_suggestion.rb
@@ -4,8 +4,7 @@ class FollowSuggestion
       neo = Neography::Rest.new
 
       query = <<END
-START a=node:account_index(Account={id})
-MATCH (a)-[:follows]->(b)-[:follows]->(c)
+MATCH (a {account_id: {id}})-[:follows]->(b)-[:follows]->(c)
 WHERE a <> c
 AND NOT (a)-[:follows]->(c)
 RETURN DISTINCT c.account_id, count(b), c.nodeRank
@@ -37,8 +36,11 @@ END
       neo = Neography::Rest.new
 
       query = <<END
+OPTIONAL MATCH (a {account_id: {id}})
+WITH a
 MATCH (b)
-WHERE b.account_id <> {id}
+WHERE b <> a
+AND NOT (a)-[:follows]->(b)
 RETURN b.account_id
 ORDER BY b.nodeRank DESC
 LIMIT {limit}