about summary refs log tree commit diff
path: root/app/lib/potential_friendship_tracker.rb
diff options
context:
space:
mode:
authorClaire <claire.github-309c@sitedethib.com>2021-04-20 18:06:40 +0200
committerGitHub <noreply@github.com>2021-04-20 18:06:40 +0200
commit97da7b73071e9f515c4bb0bca72c88d1a13b14aa (patch)
tree89c81064b9e3725962a847e98099a5b84b728733 /app/lib/potential_friendship_tracker.rb
parentdf326b8b5c0659edb2aca77690a892f228b0e099 (diff)
parent4b115d070c9a8b6082ed207bd0a14e809eded322 (diff)
Merge pull request #1521 from ClearlyClaire/glitch-soc/merge-upstream
Merge upstream changes
Diffstat (limited to 'app/lib/potential_friendship_tracker.rb')
-rw-r--r--app/lib/potential_friendship_tracker.rb12
1 files changed, 8 insertions, 4 deletions
diff --git a/app/lib/potential_friendship_tracker.rb b/app/lib/potential_friendship_tracker.rb
index 188aa4a27..e72d454b6 100644
--- a/app/lib/potential_friendship_tracker.rb
+++ b/app/lib/potential_friendship_tracker.rb
@@ -28,10 +28,14 @@ class PotentialFriendshipTracker
       redis.zrem("interactions:#{account_id}", target_account_id)
     end
 
-    def get(account_id, limit: 20, offset: 0)
-      account_ids = redis.zrevrange("interactions:#{account_id}", offset, limit)
-      return [] if account_ids.empty?
-      Account.searchable.where(id: account_ids)
+    def get(account, limit)
+      account_ids = redis.zrevrange("interactions:#{account.id}", 0, limit)
+
+      return [] if account_ids.empty? || limit < 1
+
+      accounts = Account.searchable.where(id: account_ids).index_by(&:id)
+
+      account_ids.map { |id| accounts[id.to_i] }.compact
     end
   end
 end