diff options
author | Eugen Rochko <eugen@zeonfederated.com> | 2018-11-16 15:02:18 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-11-16 15:02:18 +0100 |
commit | 8069fd636ba14059524303ce76abe2173c4f3d01 (patch) | |
tree | 55dd4f8ecd39813080cb5ddedd834f93a7ffc919 /app/models/trending_tags.rb | |
parent | 367ad2199509e9008c04c08f3476e236b27b52a1 (diff) |
Remove intermediary arrays when creating hash maps from results (#9291)
Diffstat (limited to 'app/models/trending_tags.rb')
-rw-r--r-- | app/models/trending_tags.rb | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/app/models/trending_tags.rb b/app/models/trending_tags.rb index c559651c6..3a8be2164 100644 --- a/app/models/trending_tags.rb +++ b/app/models/trending_tags.rb @@ -18,7 +18,7 @@ class TrendingTags def get(limit) key = "#{KEY}:#{Time.now.utc.beginning_of_day.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 + tags = Tag.where(id: tag_ids).to_a.each_with_object({}) { |tag, h| h[tag.id] = tag } tag_ids.map { |tag_id| tags[tag_id] }.compact end |