summaryrefslogtreecommitdiff
path: root/app/workers/bulk_imports/relation_export_worker.rb
blob: 9d9449e3a1b74b7a91cdd4f59d2c580240213660 (plain)
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
# frozen_string_literal: true

module BulkImports
  class RelationExportWorker
    include ApplicationWorker
    include ExceptionBacktrace

    idempotent!
    loggable_arguments 2, 3
    feature_category :importers
    tags :exclude_from_kubernetes
    sidekiq_options status_expiration: StuckExportJobsWorker::EXPORT_JOBS_EXPIRATION

    def perform(user_id, portable_id, portable_class, relation)
      user = User.find(user_id)
      portable = portable(portable_id, portable_class)

      RelationExportService.new(user, portable, relation, jid).execute
    end

    private

    def portable(portable_id, portable_class)
      portable_class.classify.constantize.find(portable_id)
    end
  end
end