DEV: small refactor of the category_moderators method (PR #12550)

Used index_by(&:id) instead of map { |u| [u.id, u] }.to_h thanks to @cvx’s recommendation.

Also renamed the moderators variable to not clash with method of the same name.

GitHub

How about more code golf? :stuck_out_tongue:

      CategoryMods.new(row.category_id, mods.values_at(row.user_ids))
1 Like

Hm, that didn’t work as expected :eyes:

My bad, values_at accepts varargs, not an array:

      CategoryMods.new(row.category_id, mods.values_at(*row.user_ids))