Browse Source

Fix number of results returned from TrendingTags.get

pull/4/head
Eugen Rochko 5 years ago
committed by GitHub
parent
commit
69c34f3438
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 1 deletions
  1. +1
    -1
      app/models/trending_tags.rb

+ 1
- 1
app/models/trending_tags.rb View 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

Loading…
Cancel
Save