mirror of
https://github.com/mastodon/mastodon.git
synced 2026-03-14 22:44:08 +00:00
Fix Style/ReduceToHash cop (#38088)
This commit is contained in:
parent
3a796544e3
commit
fcc3fac8a8
|
|
@ -71,7 +71,7 @@ class EmojiFormatter
|
|||
private
|
||||
|
||||
def emoji_map
|
||||
@emoji_map ||= custom_emojis.each_with_object({}) { |e, h| h[e.shortcode] = [full_asset_url(e.image.url), full_asset_url(e.image.url(:static))] }
|
||||
@emoji_map ||= custom_emojis.to_h { |e| [e.shortcode, [full_asset_url(e.image.url), full_asset_url(e.image.url(:static))]] }
|
||||
end
|
||||
|
||||
def tag_for_emoji(shortcode, emoji)
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ class Importer::BaseImporter
|
|||
raise ActiveRecord::UnknownPrimaryKey, index.adapter.target if primary_key.nil?
|
||||
|
||||
ids = documents.pluck('_id')
|
||||
existence_map = index.adapter.target.where(primary_key => ids).pluck(primary_key).each_with_object({}) { |id, map| map[id.to_s] = true }
|
||||
existence_map = index.adapter.target.where(primary_key => ids).pluck(primary_key).to_h { |id| [id.to_s, true] }
|
||||
tmp = ids.reject { |id| existence_map[id] }
|
||||
|
||||
next if tmp.empty?
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ class AccountRelationshipsPresenter
|
|||
Rails.cache.write_multi(to_cache, expires_in: 1.day)
|
||||
|
||||
# Return formatted value
|
||||
@accounts.each_with_object({}) { |account, h| h[account.id] = blocks_by_domain[account.domain] }
|
||||
@accounts.to_h { |account| [account.id, blocks_by_domain[account.domain]] }
|
||||
end
|
||||
|
||||
def cached
|
||||
|
|
|
|||
|
|
@ -8,8 +8,8 @@ class TagRelationshipsPresenter
|
|||
@following_map = {}
|
||||
@featuring_map = {}
|
||||
else
|
||||
@following_map = TagFollow.select(:tag_id).where(tag_id: tags.map(&:id), account_id: current_account_id).each_with_object({}) { |f, h| h[f.tag_id] = true }.merge(options[:following_map] || {})
|
||||
@featuring_map = FeaturedTag.select(:tag_id).where(tag_id: tags.map(&:id), account_id: current_account_id).each_with_object({}) { |f, h| h[f.tag_id] = true }.merge(options[:featuring_map] || {})
|
||||
@following_map = TagFollow.select(:tag_id).where(tag_id: tags.map(&:id), account_id: current_account_id).to_h { |f| [f.tag_id, true] }.merge(options[:following_map] || {})
|
||||
@featuring_map = FeaturedTag.select(:tag_id).where(tag_id: tags.map(&:id), account_id: current_account_id).to_h { |f| [f.tag_id, true] }.merge(options[:featuring_map] || {})
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user