This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# APP 1: Import Class | |
class Import | |
include Mongoid::Document | |
include Mongoid::Timestamps | |
include Mongoid::Paperclip | |
field :starter_at, type: Time | |
field :finished_at, type: Time | |
field :total_rows, type: Integer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def load_imported_campaign | |
total_chunks = SmarterCSV.process(file.path, {:chunk_size => 2, :strings_as_keys => true, :remove_unmapped_keys => true, :col_sep => "\t"}) do |chunk| | |
chunk.each_with_index do |h, i| | |
forkPID = fork do | |
p "Start new FORK with PID: #{forkPID} on ROW: #{i}" | |
# ESTO ES PARA EL USUARIO | |
# user = User.where(email: row["General-Email"]).first_or_create | |
# user.update(email: row["General-Email"]) | |
# user.save! |