Class: Imports::ProcessorService
- Inherits:
-
Object
- Object
- Imports::ProcessorService
- Defined in:
- app/services/imports/processor_service.rb
Instance Attribute Summary collapse
-
#execution ⇒ Object
readonly
Returns the value of attribute execution.
-
#migration_plan ⇒ Object
readonly
Returns the value of attribute migration_plan.
-
#uploaded_file ⇒ Object
readonly
Returns the value of attribute uploaded_file.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(migration_plan, execution, uploaded_file_path) ⇒ ProcessorService
constructor
A new instance of ProcessorService.
Constructor Details
#initialize(migration_plan, execution, uploaded_file_path) ⇒ ProcessorService
Returns a new instance of ProcessorService.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'app/services/imports/processor_service.rb', line 12 def initialize(migration_plan, execution, uploaded_file_path) @migration_plan = migration_plan @execution = execution @uploaded_file_path = uploaded_file_path @stats = { total_steps: migration_plan.migration_steps.count, completed_steps: 0, total_records: 0, processed_records: 0, created: 0, updated: 0, skipped: 0, failed: 0, total_attachments: 0, processed_attachments: 0, errors: [] } @id_mapping = {} # Maps old IDs to new IDs for foreign key updates @temp_dir = nil end |
Instance Attribute Details
#execution ⇒ Object (readonly)
Returns the value of attribute execution.
10 11 12 |
# File 'app/services/imports/processor_service.rb', line 10 def execution @execution end |
#migration_plan ⇒ Object (readonly)
Returns the value of attribute migration_plan.
10 11 12 |
# File 'app/services/imports/processor_service.rb', line 10 def migration_plan @migration_plan end |
#uploaded_file ⇒ Object (readonly)
Returns the value of attribute uploaded_file.
10 11 12 |
# File 'app/services/imports/processor_service.rb', line 10 def uploaded_file @uploaded_file end |
Instance Method Details
#call ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 |
# File 'app/services/imports/processor_service.rb', line 33 def call execution.update!(status: :running, started_at: Time.current) Dir.mktmpdir do |temp_dir| extract_archive(temp_dir) import_all_steps(temp_dir) finalize_success rescue StandardError => e finalize_failure(e) end end |