diff options
author | Claire <claire.github-309c@sitedethib.com> | 2021-04-20 18:06:40 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-20 18:06:40 +0200 |
commit | 97da7b73071e9f515c4bb0bca72c88d1a13b14aa (patch) | |
tree | 89c81064b9e3725962a847e98099a5b84b728733 /app/lib/potential_friendship_tracker.rb | |
parent | df326b8b5c0659edb2aca77690a892f228b0e099 (diff) | |
parent | 4b115d070c9a8b6082ed207bd0a14e809eded322 (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.rb | 12 |
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 |