Contacts now importing
This commit is contained in:
parent
aa624b4df0
commit
6abedf5f87
2 changed files with 45 additions and 0 deletions
|
|
@ -77,6 +77,21 @@ module DataConversion
|
|||
SQL
|
||||
log "Imported #{Aspect.count} aspects."
|
||||
end
|
||||
def process_raw_contacts
|
||||
log "Importing contacts to main table..."
|
||||
Contact.connection.execute <<-SQL
|
||||
INSERT INTO contacts
|
||||
SELECT mongo_contacts.id,
|
||||
users.id,
|
||||
people.id,
|
||||
mongo_contacts.pending,
|
||||
mongo_contacts.created_at,
|
||||
mongo_contacts.updated_at,
|
||||
mongo_contacts.mongo_id
|
||||
FROM mongo_contacts INNER JOIN (users, people) ON (users.mongo_id = mongo_contacts.user_mongo_id AND people.mongo_id = mongo_contacts.person_mongo_id)
|
||||
SQL
|
||||
log "Imported #{Contact.count} contacts."
|
||||
end
|
||||
def process_raw_services
|
||||
log "Importing services to main table..."
|
||||
Service.connection.execute <<-SQL
|
||||
|
|
|
|||
|
|
@ -156,6 +156,36 @@ describe DataConversion::ImportToMysql do
|
|||
person.diaspora_handle.should include(person.owner.username)
|
||||
end
|
||||
end
|
||||
describe "contacts" do
|
||||
before do
|
||||
copy_fixture_for("users")
|
||||
@migrator.import_raw_users
|
||||
@migrator.process_raw_users
|
||||
copy_fixture_for("people")
|
||||
@migrator.import_raw_people
|
||||
@migrator.process_raw_people
|
||||
copy_fixture_for("contacts")
|
||||
@migrator.import_raw_contacts
|
||||
end
|
||||
|
||||
it "imports data into the mongo_contacts table" do
|
||||
Mongo::Contact.count.should == 6
|
||||
Contact.count.should == 0
|
||||
@migrator.process_raw_contacts
|
||||
Contact.count.should == 6
|
||||
end
|
||||
|
||||
it "imports all the columns" do
|
||||
@migrator.process_raw_contacts
|
||||
contact = Contact.first
|
||||
contact.mongo_id.should == "4d2657eacc8cb4603300000d"
|
||||
contact.user_id.should == User.where(:mongo_id => "4d2657e9cc8cb46033000005").first.id
|
||||
contact.person_id.should == Person.where(:mongo_id => "4d2657eacc8cb4603300000c").first.id
|
||||
contact.pending.should be_false
|
||||
contact.created_at.should be_nil
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
describe "#import_raw" do
|
||||
describe "aspects" do
|
||||
|
|
|
|||
Loading…
Reference in a new issue