about summary refs log tree commit diff
path: root/lib/mastodon/media_cli.rb
diff options
context:
space:
mode:
authorThibG <thib@sitedethib.com>2021-01-12 09:27:38 +0100
committerGitHub <noreply@github.com>2021-01-12 09:27:38 +0100
commit54d4e5252be8cd9fa780df46e06541da8263d368 (patch)
tree36ea8ee8f190ed388b7eb5f789ff1d305230b0fd /lib/mastodon/media_cli.rb
parent7bed25f3eabecc84268a4b6c254cc3e0738926b6 (diff)
Use Rails' index_by where it makes sense (#15542)
* Use Rails' index_by where it makes sense

* Fix tests

Co-authored-by: Claire <claire.github-309c@sitedethib.com>
Diffstat (limited to 'lib/mastodon/media_cli.rb')
-rw-r--r--lib/mastodon/media_cli.rb2
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/mastodon/media_cli.rb b/lib/mastodon/media_cli.rb
index 5f4a414b1..59c118500 100644
--- a/lib/mastodon/media_cli.rb
+++ b/lib/mastodon/media_cli.rb
@@ -326,7 +326,7 @@ module Mastodon
       end
 
       preload_map.each_with_object({}) do |(model_name, record_ids), model_map|
-        model_map[model_name] = model_name.constantize.where(id: record_ids).each_with_object({}) { |record, record_map| record_map[record.id] = record }
+        model_map[model_name] = model_name.constantize.where(id: record_ids).index_by(&:id)
       end
     end
   end