Skip to content
Extraits de code Groupes Projets
Valider aa624b4d rédigé par Raphael's avatar Raphael
Parcourir les fichiers

People now importing, additional failing tests on imported times

parent 8885b8a3
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -97,6 +97,23 @@ module DataConversion ...@@ -97,6 +97,23 @@ module DataConversion
SQL SQL
log "Imported #{Service.count} services." log "Imported #{Service.count} services."
end end
def process_raw_people
log "Importing people to main table..."
Person.connection.execute <<-SQL
INSERT INTO people
SELECT mongo_people.id,
mongo_people.guid,
mongo_people.url,
mongo_people.diaspora_handle,
mongo_people.serialized_public_key,
users.id,
mongo_people.created_at,
mongo_people.updated_at,
mongo_people.mongo_id
FROM mongo_people LEFT JOIN users ON (users.mongo_id = mongo_people.owner_mongo_id)
SQL
log "Imported #{Person.count} people."
end
def import_raw_users def import_raw_users
log "Loading users file..." log "Loading users file..."
Mongo::User.connection.execute <<-SQL Mongo::User.connection.execute <<-SQL
......
...@@ -112,6 +112,50 @@ describe DataConversion::ImportToMysql do ...@@ -112,6 +112,50 @@ describe DataConversion::ImportToMysql do
service.user_id.should == User.where(:mongo_id => service.user_mongo_id).first.id service.user_id.should == User.where(:mongo_id => service.user_mongo_id).first.id
end end
end end
describe "people" do
before do
copy_fixture_for("users")
@migrator.import_raw_users
@migrator.process_raw_users
copy_fixture_for("people")
@migrator.import_raw_people
end
it "imports data into the people table" do
Mongo::Person.count.should == 10
Person.count.should == 0
@migrator.process_raw_people
Person.count.should == 10
end
it "imports all the columns of a non-owned person" do
@migrator.process_raw_people
person = Person.first
person.owner_id.should be_nil
person.mongo_id.should == "4d2657e9cc8cb46033000002"
person.guid.should == person.mongo_id
person.url.should == "http://google-10ce30d.com/"
person.diaspora_handle.should == "bob-person-19732b3@aol.com"
person.serialized_public_key.should_not be_nil
person.created_at.to_i.should == 1294358505
end
it "imports all the columns of an owned person" do
@migrator.process_raw_people
person = Person.where(:owner_id => User.first.id).first
person.mongo_id.should == "4d2657e9cc8cb46033000008"
person.guid.should == person.mongo_id
person.url.should == "http://google-4328940.com/"
person.diaspora_handle.should == "bob14cbf20@localhost"
person.serialized_public_key.should_not be_nil
person.created_at.to_i.should == 1294358506
end
it 'sets the relational column of an owned person' do
@migrator.process_raw_people
person = Person.where(:owner_id => User.first.id).first
person.should_not be_nil
person.diaspora_handle.should include(person.owner.username)
end
end
end end
describe "#import_raw" do describe "#import_raw" do
describe "aspects" do describe "aspects" do
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter