gearheads
/
mastodon
Archived
2
0
Fork 0

Use Enumerable#filter_map in more places (#15527)

gh/stable
luigi 2021-01-22 10:28:15 -05:00 committed by GitHub
parent bc4efd5e98
commit 7ea9588520
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 8 deletions

View File

@ -186,9 +186,9 @@ class SpamCheck
def matching_status_ids def matching_status_ids
if nilsimsa? if nilsimsa?
other_digests.select { |record| record.start_with?('nilsimsa') && nilsimsa_compare_value(digest, record.split(':')[1]) >= NILSIMSA_COMPARE_THRESHOLD }.filter_map { |record| record.split(':')[2] } other_digests.filter_map { |record| record.split(':')[2] if record.start_with?('nilsimsa') && nilsimsa_compare_value(digest, record.split(':')[1]) >= NILSIMSA_COMPARE_THRESHOLD }
else else
other_digests.select { |record| record.start_with?('md5') && record.split(':')[1] == digest }.filter_map { |record| record.split(':')[2] } other_digests.filter_map { |record| record.split(':')[2] if record.start_with?('md5') && record.split(':')[1] == digest }
end end
end end

View File

@ -15,7 +15,7 @@ class StatusRelationshipsPresenter
statuses = statuses.compact statuses = statuses.compact
status_ids = statuses.flat_map { |s| [s.id, s.reblog_of_id] }.uniq.compact status_ids = statuses.flat_map { |s| [s.id, s.reblog_of_id] }.uniq.compact
conversation_ids = statuses.filter_map(&:conversation_id).uniq conversation_ids = statuses.filter_map(&:conversation_id).uniq
pinnable_status_ids = statuses.map(&:proper).select { |s| s.account_id == current_account_id && %w(public unlisted).include?(s.visibility) }.map(&:id) pinnable_status_ids = statuses.map(&:proper).filter_map { |s| s.id if s.account_id == current_account_id && %w(public unlisted).include?(s.visibility) }
@reblogs_map = Status.reblogs_map(status_ids, current_account_id).merge(options[:reblogs_map] || {}) @reblogs_map = Status.reblogs_map(status_ids, current_account_id).merge(options[:reblogs_map] || {})
@favourites_map = Status.favourites_map(status_ids, current_account_id).merge(options[:favourites_map] || {}) @favourites_map = Status.favourites_map(status_ids, current_account_id).merge(options[:favourites_map] || {})

View File

@ -23,11 +23,8 @@ class ActivityPub::FetchFeaturedCollectionService < BaseService
def process_items(items) def process_items(items)
status_ids = items.map { |item| value_or_id(item) } status_ids = items.map { |item| value_or_id(item) }
.reject { |uri| ActivityPub::TagManager.instance.local_uri?(uri) } .filter_map { |uri| ActivityPub::FetchRemoteStatusService.new.call(uri) unless ActivityPub::TagManager.instance.local_uri?(uri) }
.filter_map { |uri| ActivityPub::FetchRemoteStatusService.new.call(uri) } .filter_map { |status| status.id if status.account_id == @account.id }
.select { |status| status.account_id == @account.id }
.map(&:id)
to_remove = [] to_remove = []
to_add = status_ids to_add = status_ids