Fix Style/ReduceToHash cop (#38088)

This commit is contained in:
Matt Jankowski
2026-03-09 06:01:12 -04:00
committed by GitHub
parent 3a796544e3
commit fcc3fac8a8
6 changed files with 21 additions and 21 deletions

View File

@@ -5,12 +5,12 @@ module Account::Mappings
class_methods do
def following_map(target_account_ids, account_id)
Follow.where(target_account_id: target_account_ids, account_id: account_id).each_with_object({}) do |follow, mapping|
mapping[follow.target_account_id] = {
Follow.where(target_account_id: target_account_ids, account_id: account_id).to_h do |follow|
[follow.target_account_id, {
reblogs: follow.show_reblogs?,
notify: follow.notify?,
languages: follow.languages,
}
}]
end
end
@@ -36,21 +36,21 @@ module Account::Mappings
end
def muting_map(target_account_ids, account_id)
Mute.where(target_account_id: target_account_ids, account_id: account_id).each_with_object({}) do |mute, mapping|
mapping[mute.target_account_id] = {
Mute.where(target_account_id: target_account_ids, account_id: account_id).to_h do |mute|
[mute.target_account_id, {
notifications: mute.hide_notifications?,
expires_at: mute.expires_at,
}
}]
end
end
def requested_map(target_account_ids, account_id)
FollowRequest.where(target_account_id: target_account_ids, account_id: account_id).each_with_object({}) do |follow_request, mapping|
mapping[follow_request.target_account_id] = {
FollowRequest.where(target_account_id: target_account_ids, account_id: account_id).to_h do |follow_request|
[follow_request.target_account_id, {
reblogs: follow_request.show_reblogs?,
notify: follow_request.notify?,
languages: follow_request.languages,
}
}]
end
end
@@ -69,10 +69,10 @@ module Account::Mappings
end
def account_note_map(target_account_ids, account_id)
AccountNote.where(target_account_id: target_account_ids, account_id: account_id).each_with_object({}) do |note, mapping|
mapping[note.target_account_id] = {
AccountNote.where(target_account_id: target_account_ids, account_id: account_id).to_h do |note|
[note.target_account_id, {
comment: note.comment,
}
}]
end
end

View File

@@ -362,7 +362,7 @@ class Status < ApplicationRecord
class << self
def favourites_map(status_ids, account_id)
Favourite.select(:status_id).where(status_id: status_ids).where(account_id: account_id).each_with_object({}) { |f, h| h[f.status_id] = true }
Favourite.select(:status_id).where(status_id: status_ids).where(account_id: account_id).to_h { |f| [f.status_id, true] }
end
def bookmarks_map(status_ids, account_id)
@@ -370,15 +370,15 @@ class Status < ApplicationRecord
end
def reblogs_map(status_ids, account_id)
unscoped.select(:reblog_of_id).where(reblog_of_id: status_ids).where(account_id: account_id).each_with_object({}) { |s, h| h[s.reblog_of_id] = true }
unscoped.select(:reblog_of_id).where(reblog_of_id: status_ids).where(account_id: account_id).to_h { |s| [s.reblog_of_id, true] }
end
def mutes_map(conversation_ids, account_id)
ConversationMute.select(:conversation_id).where(conversation_id: conversation_ids).where(account_id: account_id).each_with_object({}) { |m, h| h[m.conversation_id] = true }
ConversationMute.select(:conversation_id).where(conversation_id: conversation_ids).where(account_id: account_id).to_h { |m| [m.conversation_id, true] }
end
def pins_map(status_ids, account_id)
StatusPin.select(:status_id).where(status_id: status_ids).where(account_id: account_id).each_with_object({}) { |p, h| h[p.status_id] = true }
StatusPin.select(:status_id).where(status_id: status_ids).where(account_id: account_id).to_h { |p| [p.status_id, true] }
end
def from_text(text)