From 54d4e5252be8cd9fa780df46e06541da8263d368 Mon Sep 17 00:00:00 2001 From: ThibG Date: Tue, 12 Jan 2021 09:27:38 +0100 Subject: Use Rails' index_by where it makes sense (#15542) * Use Rails' index_by where it makes sense * Fix tests Co-authored-by: Claire --- app/models/trending_tags.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app/models/trending_tags.rb') diff --git a/app/models/trending_tags.rb b/app/models/trending_tags.rb index c69f6d3c3..9c2aa0ee8 100644 --- a/app/models/trending_tags.rb +++ b/app/models/trending_tags.rb @@ -91,7 +91,7 @@ class TrendingTags tags = Tag.where(id: tag_ids) tags = tags.trendable if filtered - tags = tags.each_with_object({}) { |tag, h| h[tag.id] = tag } + tags = tags.index_by(&:id) tag_ids.map { |tag_id| tags[tag_id] }.compact.take(limit) end -- cgit