Class: Exports::GeneratorService
- Inherits:
-
Object
- Object
- Exports::GeneratorService
- Defined in:
- app/services/exports/generator_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.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(migration_plan, execution) ⇒ GeneratorService
constructor
A new instance of GeneratorService.
Constructor Details
#initialize(migration_plan, execution) ⇒ GeneratorService
Returns a new instance of GeneratorService.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'app/services/exports/generator_service.rb', line 12 def initialize(migration_plan, execution) @migration_plan = migration_plan @execution = execution @stats = { total_steps: migration_plan.migration_steps.count, completed_steps: 0, total_records: 0, processed_records: 0, total_attachments: 0, processed_attachments: 0, errors: [] } @exported_ids_cache = {} # Cache format: { step_id => { 'column_name' => [values] } } @temp_dir = nil end |
Instance Attribute Details
#execution ⇒ Object (readonly)
Returns the value of attribute execution.
10 11 12 |
# File 'app/services/exports/generator_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/exports/generator_service.rb', line 10 def migration_plan @migration_plan end |
Instance Method Details
#call ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 |
# File 'app/services/exports/generator_service.rb', line 28 def call execution.update!(status: :running, started_at: Time.current) Dir.mktmpdir do |temp_dir| export_all_steps(temp_dir) archive_path = create_archive(temp_dir) finalize_success(archive_path) rescue StandardError => e finalize_failure(e) end end |