Created
June 13, 2012 14:21
-
-
Save jmoren/2924386 to your computer and use it in GitHub Desktop.
modificaciones csv
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
#@sql = "LOAD DATA LOCAL INFILE '/tmp/hh_import_#{@user.id}#{rand_filename}.tsv' INTO TABLE contacts (phone) SET user_id=#{@user.id},status=#{import_type},import=1,created_at=UTC_TIMESTAMP(),updated_at=UTC_TIMESTAMP()" | |
#ActiveRecord::Base.connection.execute(@sql) if @exists_phones.length > 0 #.join adds a \n to empty arrays | |
@contacts = Contact.create( | |
@exists_phones.map{|phone| {:phone => phone, :status => import_type, :user_id => @user.id, :import => 1} } | |
) | |
ids = @contacts.map(&:id) | |
@q_contacts = QcallContact.create( | |
ids.map{|contact_id| {:qcall_contact_list_id => @q_new_list.id, :qpriority => 10, :qcall_id => @qcall.id, :contact_id => contact_id } } | |
) unless ids.empty? | |
#@sql = "INSERT INTO qcall_contacts (qcall_contact_list_id,qpriority,qcall_id,contact_id,updated_at,created_at) SELECT #{@q_new_list.id},10,#{@qcall.id},id,UTC_TIMESTAMP(),UTC_TIMESTAMP() FROM contacts WHERE user_id=#{@user.id} AND import=1 ORDER BY id" | |
#ActiveRecord::Base.connection.execute(@sql) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment