Start profile import, fixtures are wrong

This commit is contained in:
Raphael 2011-01-10 12:25:13 -08:00
parent 47ed820dea
commit 92aecb3bec
2 changed files with 66 additions and 1 deletions

View file

@ -42,7 +42,7 @@ module DataConversion
process_raw_aspect_memberships
process_raw_invitations
process_raw_requests
#profiles
process_raw_profiles
#posts
#post_visibilities
#notifications
@ -106,6 +106,31 @@ module DataConversion
SQL
log "Imported #{Contact.count} contacts."
end
def process_raw_profiles
log "Importing profiles to main table..."
debugger
Profile.connection.execute <<-SQL
INSERT INTO profiles
SELECT mongo_profiles.id,
mongo_profiles.diaspora_handle,
mongo_profiles.first_name,
mongo_profiles.last_name,
mongo_profiles.image_url,
mongo_profiles.image_url_small,
mongo_profiles.image_url_medium,
mongo_profiles.birthday,
mongo_profiles.gender,
mongo_profiles.bio,
mongo_profiles.searchable,
people.id,
mongo_profiles.created_at,
mongo_profiles.updated_at,
mongo_profiles.person_mongo_id
FROM mongo_profiles
INNER JOIN (people) ON (people.mongo_id = mongo_profiles.person_mongo_id)
SQL
log "Imported #{Profile.count} profiles."
end
def process_raw_aspect_memberships
log "Importing aspect_memberships to main table..."
AspectMembership.connection.execute <<-SQL

View file

@ -291,6 +291,46 @@ describe DataConversion::ImportToMysql do
aspectm.aspect_id.should == Aspect.where(:mongo_id => "4d2657e9cc8cb46033000006").first.id
end
end
describe "profiles" 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("profiles")
@migrator.import_raw_profiles
end
it "processs data into the mongo_profiles table" do
Mongo::Profile.count.should == 10
Profile.count.should == 0
@migrator.process_raw_profiles
Profile.count.should == 10
end
it "processs all the columns" do
@migrator.process_raw_profiles
profile = Profile.first
profile.image_url_medium.should be_nil
profile.searchable.should == true
profile.image_url.should be_nil
profile.person_mongo_id.should == "4d2657e8cc8cb46033000001"
profile.gender.should be_nil
profile.diaspora_handle.should be_nil
profile.birthday.should be_nil
profile.last_name.should == 'weinstien'
profile.bio.should be_nil
profile.image_url_small.should be_nil
profile.first_name.should == 'eugene'
end
it "sets the relation to person" do
@migrator.process_raw_profiles
profile = Profile.first
profile.person_id.should == Person.where(:mongo_id => profile.person_mongo_id).first.id
end
end
end
describe "#import_raw" do
describe "aspects" do