]> cat aescling's git repositories - mastodon.git/commitdiff
Fix number of results returned from TrendingTags.get
authorEugen Rochko <eugen@zeonfederated.com>
Mon, 16 Jul 2018 17:54:14 +0000 (19:54 +0200)
committerGitHub <noreply@github.com>
Mon, 16 Jul 2018 17:54:14 +0000 (19:54 +0200)
app/models/trending_tags.rb

index b11f352929c7cd056bc2280055d4b9574fb47da1..c559651c666862aebb6c60aadffa6b9f8db80f98 100644 (file)
@@ -17,7 +17,7 @@ class TrendingTags
 
     def get(limit)
       key     = "#{KEY}:#{Time.now.utc.beginning_of_day.to_i}"
-      tag_ids = redis.zrevrange(key, 0, limit).map(&:to_i)
+      tag_ids = redis.zrevrange(key, 0, limit - 1).map(&:to_i)
       tags    = Tag.where(id: tag_ids).to_a.map { |tag| [tag.id, tag] }.to_h
       tag_ids.map { |tag_id| tags[tag_id] }.compact
     end