Class: Decidim::DirectVerifications::BaseImportJob

Inherits:
ApplicationJob
  • Object
show all
Defined in:
app/jobs/decidim/direct_verifications/base_import_job.rb

Overview

This class implements the logic to import the user entries and sending an email notification with the result. The specifics to process the entries are meant to be implemented by subclasses which must implement the `#process_users` and `#type` methods.

Instance Method Summary collapse

Instance Method Details

#perform(blob_id, organization, current_user, authorization_handler, options = {}) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'app/jobs/decidim/direct_verifications/base_import_job.rb', line 13

def perform(blob_id, organization, current_user, authorization_handler, options = {})
  @blob = ActiveStorage::Blob.find(blob_id)
  @organization = organization
  @current_user = current_user
  @authorization_handler = authorization_handler

  begin
    @emails = Parsers::MetadataParser.new(userslist).to_h
    @instrumenter = Instrumenter.new(current_user)

    Rails.logger.info "BaseImportJob: Processing file #{@blob.filename}"
    process_users
    send_email_notification
  rescue StandardError => e
    Rails.logger.error "BaseImportJob Error: #{e.message} #{e.backtrace.filter { |f| f =~ /direct_verifications/ }}"
  end
  remove_file! if options.fetch(:remove_file, false)
end