lib/loader/loader.rb in myreplicator-1.1.11 vs lib/loader/loader.rb in myreplicator-1.1.12

- old
+ new

@@ -30,12 +30,16 @@ ## def self.load initials = [] incrementals = [] all_files = Myreplicator::Loader.metadata_files - + + Kernel.p "===== all_files =====" + Kernel.p all_files + all_files.each do |m| + Kernel.p m if m.export_type == "initial" initials << m # Add initial to the list all_files.delete(m) # Delete obj from mixed list all_files.each do |md| @@ -154,13 +158,13 @@ ## # Creates table and loads data ## def self.initial_load metadata exp = Export.find(metadata.export_id) - Kernel.p "===== unzip =====" - Loader.unzip(metadata.filename) - metadata.zipped = false + #Kernel.p "===== unzip =====" + #Loader.unzip(metadata.filename) + #metadata.zipped = false cmd = ImportSql.initial_load(:db => exp.destination_schema, :filepath => metadata.destination_filepath(tmp_dir)) puts cmd @@ -176,12 +180,12 @@ # Loads data incrementally # Uses the values specified in the metadatta object ## def self.incremental_load metadata exp = Export.find(metadata.export_id) - Loader.unzip(metadata.filename) - metadata.zipped = false + #Loader.unzip(metadata.filename) + #metadata.zipped = false options = {:table_name => exp.table_name, :db => exp.destination_schema, :filepath => metadata.destination_filepath(tmp_dir), :source_schema => exp.source_schema, @@ -225,12 +229,16 @@ ## # Returns true if the transfer of the file # being loaded is completed ## def self.transfer_completed? metadata + Kernel.p "===== transfer_completed? metadata =====" + Kernel.p ({:export_id => metadata.export_id, + :file => metadata.export_path, + :job_type => "transporter"}) if Log.completed?(:export_id => metadata.export_id, - :file => metadata.destination_filepath(tmp_dir), + :file => metadata.export_path, :job_type => "transporter") return true end return false end @@ -272,10 +280,31 @@ def self.metadata_files files = [] Dir.glob(File.join(tmp_dir, "*.json")).each do |json_file| files << ExportMetadata.new(:metadata_path => json_file) end - return files + result = [] + Kernel.p files + files.each do |file| + puts "<<<<<<<<<<<<<<<<" + job = Export.where("id = #{file.export_id}").first + puts "<<<<<<<<<<<<<<<<" + Kernel.p job + puts "<<<<<<<<<<<<<<<<" + puts "&&&&&&&&&&&&&&&&&&&&&&&&&&" + Kernel.p file + puts "&&&&&&&&&&&&&&&&&&&&&&&&&&" + if job.state == "transport_completed" + result << file + end + puts "^^^^^^^^^^^^^^^^^^^^^^^^^^" + Kernel.p result + puts "^^^^^^^^^^^^^^^^^^^^^^^^^^" + end + puts "<<<<<<<<<<<<<<<<" + a = gets + puts "<<<<<<<<<<<<<<<<" + return result end ## # Clears files that are older than the passed metadata file. # Note: This methoded is provided to ensure no old incremental files