Class: BulkImports::ExportStatus
- Inherits:
-
Object
- Object
- BulkImports::ExportStatus
- Includes:
- Gitlab::Utils::StrongMemoize
- Defined in:
- app/models/bulk_imports/export_status.rb
Constant Summary collapse
- CACHE_KEY =
'bulk_imports/export_status/%{entity_id}/%{relation}'
Instance Method Summary collapse
- #batch(batch_number) ⇒ Object
- #batched? ⇒ Boolean
- #batches_count ⇒ Object
- #empty? ⇒ Boolean
- #error ⇒ Object
- #failed? ⇒ Boolean
- #in_progress? ⇒ Boolean
-
#initialize(pipeline_tracker, relation) ⇒ ExportStatus
constructor
A new instance of ExportStatus.
- #total_objects_count ⇒ Object
Constructor Details
#initialize(pipeline_tracker, relation) ⇒ ExportStatus
Returns a new instance of ExportStatus.
9 10 11 12 13 14 15 |
# File 'app/models/bulk_imports/export_status.rb', line 9 def initialize(pipeline_tracker, relation) @pipeline_tracker = pipeline_tracker @relation = relation @entity = @pipeline_tracker.entity @configuration = @entity.bulk_import.configuration @client = Clients::HTTP.new(url: @configuration.url, token: @configuration.access_token) end |
Instance Method Details
#batch(batch_number) ⇒ Object
41 42 43 44 45 46 47 |
# File 'app/models/bulk_imports/export_status.rb', line 41 def batch(batch_number) raise ArgumentError if batch_number < 1 return unless batched? status['batches'].find { |item| item['batch_number'] == batch_number } end |
#batched? ⇒ Boolean
33 34 35 |
# File 'app/models/bulk_imports/export_status.rb', line 33 def batched? status['batched'] == true end |
#batches_count ⇒ Object
37 38 39 |
# File 'app/models/bulk_imports/export_status.rb', line 37 def batches_count status['batches_count'].to_i end |
#empty? ⇒ Boolean
25 26 27 |
# File 'app/models/bulk_imports/export_status.rb', line 25 def empty? status.nil? end |
#error ⇒ Object
29 30 31 |
# File 'app/models/bulk_imports/export_status.rb', line 29 def error status['error'] end |
#failed? ⇒ Boolean
21 22 23 |
# File 'app/models/bulk_imports/export_status.rb', line 21 def failed? !empty? && status['status'] == Export::FAILED end |
#in_progress? ⇒ Boolean
17 18 19 |
# File 'app/models/bulk_imports/export_status.rb', line 17 def in_progress? !empty? && Export::IN_PROGRESS_STATUSES.include?(status['status']) end |
#total_objects_count ⇒ Object
49 50 51 52 53 |
# File 'app/models/bulk_imports/export_status.rb', line 49 def total_objects_count return 0 if empty? status['total_objects_count'] end |