Sha256: 19862e01c3d427a980190beb9502dfac6efadb8938e3a7c566c1fd01069ff590
Contents?: true
Size: 1.01 KB
Versions: 2
Compression:
Stored size: 1.01 KB
Contents
module BridgeCache::Jobs class ImportData < ActiveJob::Base include BridgeCache::Utils::WorkerHelper queue_as :default def perform(bridge_base_url, bridge_api_key, bridge_api_secret, models, chain = []) begin remote_data = BridgeBlueprint::RemoteData.new(bridge_base_url, bridge_api_key, bridge_api_secret) Dir.mktmpdir do |dir| path = "#{dir}/data_dump" remote_data.store_file(path) import = BridgeBlueprint::DataDump.new(path) models.each do |model| row_ids = [] import.each_row(model.pluralize) do |row| BridgeCache::Jobs::ImportRow.set(queue: self.queue_name).perform_later(model, row.to_h) row_ids << row['id'].to_i end BridgeCache::Jobs::CleanupJob.set(queue: self.queue_name).perform_later(model, row_ids) end end BridgeCache::Utils::WorkerHelper.invoke_next(chain) rescue => e Rails.logger.debug(e) end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
bridge_cache-0.2.0 | app/lib/bridge_cache/jobs/import_data.rb |
bridge_cache-0.1.0 | app/lib/bridge_cache/jobs/import_data.rb |