Merge remote-tracking branch 'parent/main' into kb_migration

This commit is contained in:
KMY 2023-09-06 10:09:07 +09:00
commit fdf1d6df38
41 changed files with 752 additions and 569 deletions

View file

@ -38,7 +38,7 @@ class BulkImportService < BaseService
rows_by_acct = extract_rows_by_acct
if @import.overwrite?
@account.following.find_each do |followee|
@account.following.reorder(nil).find_each do |followee|
row = rows_by_acct.delete(followee.acct)
if row.nil?
@ -67,7 +67,7 @@ class BulkImportService < BaseService
rows_by_acct = extract_rows_by_acct
if @import.overwrite?
@account.blocking.find_each do |blocked_account|
@account.blocking.reorder(nil).find_each do |blocked_account|
row = rows_by_acct.delete(blocked_account.acct)
if row.nil?
@ -93,7 +93,7 @@ class BulkImportService < BaseService
rows_by_acct = extract_rows_by_acct
if @import.overwrite?
@account.muting.find_each do |muted_account|
@account.muting.reorder(nil).find_each do |muted_account|
row = rows_by_acct.delete(muted_account.acct)
if row.nil?

View file

@ -75,7 +75,7 @@ class ImportService < BaseService
if @import.overwrite?
presence_hash = items.each_with_object({}) { |(id, extra), mapping| mapping[id] = [true, extra] }
overwrite_scope.find_each do |target_account|
overwrite_scope.reorder(nil).find_each do |target_account|
if presence_hash[target_account.acct]
items.delete(target_account.acct)
extra = presence_hash[target_account.acct][1]

View file

@ -15,24 +15,8 @@ class StatusesSearchService < BaseService
private
def status_search_results
definition_should = [
publicly_searchable,
non_publicly_searchable,
searchability_limited,
]
definition_should << searchability_public if %i(public).include?(@searchability)
definition_should << searchability_private if %i(public private).include?(@searchability)
definition = parsed_query.apply(
Chewy::Search::Request.new(StatusesIndex, PublicStatusesIndex).filter(
bool: {
should: definition_should,
minimum_should_match: 1,
}
)
)
results = definition.collapse(field: :id).order(id: { order: :desc }).limit(@limit).offset(@offset).objects.compact
request = parsed_query.request
results = request.collapse(field: :id).order(id: { order: :desc }).limit(@limit).offset(@offset).objects.compact
account_ids = results.map(&:account_id)
account_domains = results.map(&:account_domain)
preloaded_relations = @account.relations_map(account_ids, account_domains)
@ -42,94 +26,6 @@ class StatusesSearchService < BaseService
[]
end
def publicly_searchable
{
term: { _index: PublicStatusesIndex.index_name },
}
end
def non_publicly_searchable
{
bool: {
must: [
{
term: { _index: StatusesIndex.index_name },
},
{
exists: {
field: 'searchability',
},
},
{
term: { searchable_by: @account.id },
},
],
must_not: [
{
term: { searchability: 'limited' },
},
],
},
}
end
def searchability_public
{
bool: {
must: [
{
exists: {
field: 'searchability',
},
},
{
term: { searchability: 'public' },
},
],
},
}
end
def searchability_private
{
bool: {
must: [
{
exists: {
field: 'searchability',
},
},
{
term: { searchability: 'private' },
},
{
terms: { account_id: following_account_ids },
},
],
},
}
end
def searchability_limited
{
bool: {
must: [
{
exists: {
field: 'searchability',
},
},
{
term: { searchability: 'limited' },
},
{
term: { account_id: @account.id },
},
],
},
}
end
def following_account_ids
return @following_account_ids if defined?(@following_account_ids)
@ -140,6 +36,6 @@ class StatusesSearchService < BaseService
end
def parsed_query
SearchQueryTransformer.new.apply(SearchQueryParser.new.parse(@query), current_account: @account)
SearchQueryTransformer.new.apply(SearchQueryParser.new.parse(@query), current_account: @account, searchability: @searchability)
end
end

View file

@ -51,13 +51,13 @@ class SuspendAccountService < BaseService
end
def unmerge_from_home_timelines!
@account.followers_for_local_distribution.find_each do |follower|
@account.followers_for_local_distribution.reorder(nil).find_each do |follower|
FeedManager.instance.unmerge_from_home(@account, follower)
end
end
def unmerge_from_list_timelines!
@account.lists_for_local_distribution.find_each do |list|
@account.lists_for_local_distribution.reorder(nil).find_each do |list|
FeedManager.instance.unmerge_from_list(@account, list)
end
end
@ -65,7 +65,7 @@ class SuspendAccountService < BaseService
def privatize_media_attachments!
attachment_names = MediaAttachment.attachment_definitions.keys
@account.media_attachments.find_each do |media_attachment|
@account.media_attachments.reorder(nil).find_each do |media_attachment|
attachment_names.each do |attachment_name|
attachment = media_attachment.public_send(attachment_name)
styles = MediaAttachment::DEFAULT_STYLES | attachment.styles.keys

View file

@ -47,13 +47,13 @@ class UnsuspendAccountService < BaseService
end
def merge_into_home_timelines!
@account.followers_for_local_distribution.find_each do |follower|
@account.followers_for_local_distribution.reorder(nil).find_each do |follower|
FeedManager.instance.merge_into_home(@account, follower)
end
end
def merge_into_list_timelines!
@account.lists_for_local_distribution.find_each do |list|
@account.lists_for_local_distribution.reorder(nil).find_each do |list|
FeedManager.instance.merge_into_list(@account, list)
end
end
@ -61,7 +61,7 @@ class UnsuspendAccountService < BaseService
def publish_media_attachments!
attachment_names = MediaAttachment.attachment_definitions.keys
@account.media_attachments.find_each do |media_attachment|
@account.media_attachments.reorder(nil).find_each do |media_attachment|
attachment_names.each do |attachment_name|
attachment = media_attachment.public_send(attachment_name)
styles = MediaAttachment::DEFAULT_STYLES | attachment.styles.keys