Add importing remote post

This commit is contained in:
KMY 2023-09-15 18:51:46 +09:00
parent 5fb6bce744
commit ddce464d70
4 changed files with 17 additions and 4 deletions

View file

@ -3,9 +3,10 @@
class Importer::BaseImporter
# @param [Integer] batch_size
# @param [Concurrent::ThreadPoolExecutor] executor
def initialize(batch_size:, executor:)
def initialize(batch_size:, executor:, full: true)
@batch_size = batch_size
@executor = executor
@full = full
@wait_for = Concurrent::Set.new
end

View file

@ -21,7 +21,7 @@ class Importer::StatusesIndexImporter < Importer::BaseImporter
to_index.map do |object|
# This is unlikely to happen, but the post may have been
# un-interacted with since it was queued for indexing
if object.searchable_by.empty?
if object.searchable_by.empty? && %w(public private).exclude?(object.searchability)
deleted += 1
{ delete: { _id: object.id } }
else
@ -49,13 +49,15 @@ class Importer::StatusesIndexImporter < Importer::BaseImporter
end
def scopes
[
targets = [
local_statuses_scope,
local_mentions_scope,
local_favourites_scope,
local_votes_scope,
local_bookmarks_scope,
]
targets << remote_searchable_scope if @full
targets
end
def local_mentions_scope
@ -77,4 +79,8 @@ class Importer::StatusesIndexImporter < Importer::BaseImporter
def local_statuses_scope
Status.local.select('"statuses"."id", COALESCE("statuses"."reblog_of_id", "statuses"."id") AS status_id')
end
def remote_searchable_scope
Status.remote_dynamic_searchability.select('"statuses"."id", COALESCE("statuses"."reblog_of_id", "statuses"."id") AS status_id')
end
end