~cytrogen/masto-fe

ref: d7254bd3327c5ad208b7f74aade749234441b3bc masto-fe/app/lib/importer/accounts_index_importer.rb -rw-r--r-- 545 bytes
d7254bd3 — Laura Hausmann Update default local-settings 2 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# frozen_string_literal: true

class Importer::AccountsIndexImporter < Importer::BaseImporter
  def import!
    scope.includes(:account_stat).find_in_batches(batch_size: @batch_size) do |tmp|
      in_work_unit(tmp) do |accounts|
        bulk = build_bulk_body(accounts)

        indexed = bulk.size
        deleted = 0

        Chewy::Index::Import::BulkRequest.new(index).perform(bulk)

        [indexed, deleted]
      end
    end

    wait!
  end

  private

  def index
    AccountsIndex
  end

  def scope
    Account.searchable
  end
end