blob: d7c126f75bff1c0f2b5a2606218b3aaca10bae8b (
plain) (
blame)
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
31
32
33
34
35
36
37
38
39
40
41
42
|
# frozen_string_literal: true
require 'csv'
class ImportWorker
include Sidekiq::Worker
sidekiq_options queue: 'pull', retry: false
attr_reader :import
def perform(import_id)
@import = Import.find(import_id)
Import::RelationshipWorker.push_bulk(import_rows) do |row|
[@import.account_id, row.first, relationship_type]
end
@import.destroy
end
private
def import_contents
Paperclip.io_adapters.for(@import.data).read
end
def relationship_type
case @import.type
when 'following'
'follow'
when 'blocking'
'block'
when 'muting'
'mute'
end
end
def import_rows
CSV.new(import_contents).reject(&:blank?)
end
end
|