Module: Bulkrax::ImporterExporterBehavior
- Extended by:
- ActiveSupport::Concern
- Defined in:
- app/models/concerns/bulkrax/importer_exporter_behavior.rb
Instance Method Summary collapse
- #increment_counters(index, collection = false) ⇒ Object
- #last_imported_at ⇒ Object
- #next_import_at ⇒ Object
- #parser ⇒ Object
- #parser_class ⇒ Object
Instance Method Details
#increment_counters(index, collection = false) ⇒ Object
23 24 25 26 27 28 29 30 31 32 |
# File 'app/models/concerns/bulkrax/importer_exporter_behavior.rb', line 23 def increment_counters(index, collection = false) # Only set the totals if they were not set on initialization if collection current_run.total_collection_entries = index + 1 unless parser.collections_total.positive? else current_run.total_work_entries = index + 1 unless limit.to_i.positive? || parser.total.positive? end current_run.enqueued_records = index + 1 current_run.save! end |
#last_imported_at ⇒ Object
15 16 17 |
# File 'app/models/concerns/bulkrax/importer_exporter_behavior.rb', line 15 def last_imported_at @last_imported_at ||= self.importer_runs.last&.created_at end |
#next_import_at ⇒ Object
19 20 21 |
# File 'app/models/concerns/bulkrax/importer_exporter_behavior.rb', line 19 def next_import_at (last_imported_at || Time.current) + frequency.to_seconds if schedulable? && last_imported_at.present? end |
#parser ⇒ Object
7 8 9 |
# File 'app/models/concerns/bulkrax/importer_exporter_behavior.rb', line 7 def parser @parser ||= parser_class.new(self) end |
#parser_class ⇒ Object
11 12 13 |
# File 'app/models/concerns/bulkrax/importer_exporter_behavior.rb', line 11 def parser_class self.parser_klass.constantize end |