Aspect memberships now importing
This commit is contained in:
parent
6abedf5f87
commit
e8d46982d8
2 changed files with 51 additions and 3 deletions
|
|
@ -50,7 +50,7 @@ module DataConversion
|
|||
Mongo::Contact.connection.execute "TRUNCATE TABLE mongo_contacts"
|
||||
Mongo::PostVisibility.connection.execute "TRUNCATE TABLE mongo_post_visibilities"
|
||||
Mongo::Request.connection.execute "TRUNCATE TABLE mongo_requests"
|
||||
Mongo::Services.connection.execute "TRUNCATE TABLE mongo_services"
|
||||
Mongo::Service.connection.execute "TRUNCATE TABLE mongo_services"
|
||||
end
|
||||
|
||||
def process_raw_users
|
||||
|
|
@ -92,6 +92,20 @@ module DataConversion
|
|||
SQL
|
||||
log "Imported #{Contact.count} contacts."
|
||||
end
|
||||
def process_raw_aspect_memberships
|
||||
log "Importing aspect_memberships to main table..."
|
||||
AspectMembership.connection.execute <<-SQL
|
||||
INSERT INTO aspect_memberships
|
||||
SELECT mongo_aspect_memberships.id,
|
||||
aspects.id,
|
||||
contacts.id,
|
||||
mongo_aspect_memberships.created_at,
|
||||
mongo_aspect_memberships.updated_at
|
||||
FROM mongo_aspect_memberships INNER JOIN (aspects, contacts)
|
||||
ON (aspects.mongo_id = mongo_aspect_memberships.aspect_mongo_id AND contacts.mongo_id = mongo_aspect_memberships.contact_mongo_id)
|
||||
SQL
|
||||
log "Imported #{AspectMembership.count} aspect_memberships."
|
||||
end
|
||||
def process_raw_services
|
||||
log "Importing services to main table..."
|
||||
Service.connection.execute <<-SQL
|
||||
|
|
|
|||
|
|
@ -19,7 +19,6 @@ describe DataConversion::ImportToMysql do
|
|||
end
|
||||
|
||||
describe "#process_raw" do
|
||||
|
||||
describe "users" do
|
||||
before do
|
||||
copy_fixture_for("users")
|
||||
|
|
@ -50,8 +49,8 @@ describe DataConversion::ImportToMysql do
|
|||
bob.reset_password_token.should be_nil
|
||||
bob.password_salt.should_not be_nil
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
describe "aspects" do
|
||||
before do
|
||||
copy_fixture_for("aspects")
|
||||
|
|
@ -79,6 +78,7 @@ describe DataConversion::ImportToMysql do
|
|||
aspect.user_id.should == User.where(:mongo_id => aspect.user_mongo_id).first.id
|
||||
end
|
||||
end
|
||||
|
||||
describe "services" do
|
||||
before do
|
||||
copy_fixture_for("users")
|
||||
|
|
@ -112,6 +112,7 @@ describe DataConversion::ImportToMysql do
|
|||
service.user_id.should == User.where(:mongo_id => service.user_mongo_id).first.id
|
||||
end
|
||||
end
|
||||
|
||||
describe "people" do
|
||||
before do
|
||||
copy_fixture_for("users")
|
||||
|
|
@ -156,6 +157,7 @@ describe DataConversion::ImportToMysql do
|
|||
person.diaspora_handle.should include(person.owner.username)
|
||||
end
|
||||
end
|
||||
|
||||
describe "contacts" do
|
||||
before do
|
||||
copy_fixture_for("users")
|
||||
|
|
@ -184,7 +186,39 @@ describe DataConversion::ImportToMysql do
|
|||
contact.pending.should be_false
|
||||
contact.created_at.should be_nil
|
||||
end
|
||||
end
|
||||
|
||||
describe "aspect_memberships" 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
|
||||
@migrator.process_raw_contacts
|
||||
copy_fixture_for("aspects")
|
||||
@migrator.import_raw_aspects
|
||||
@migrator.process_raw_aspects
|
||||
copy_fixture_for("aspect_memberships")
|
||||
@migrator.import_raw_aspect_memberships
|
||||
end
|
||||
|
||||
it "imports data into the mongo_aspect_memberships table" do
|
||||
Mongo::AspectMembership.count.should == 6
|
||||
AspectMembership.count.should == 0
|
||||
@migrator.process_raw_aspect_memberships
|
||||
AspectMembership.count.should == 6
|
||||
end
|
||||
|
||||
it "imports all the columns" do
|
||||
@migrator.process_raw_aspect_memberships
|
||||
aspectm = AspectMembership.first
|
||||
aspectm.contact_id.should == Contact.where(:mongo_id => "4d2657eacc8cb4603300000d").first.id
|
||||
aspectm.aspect_id.should == Aspect.where(:mongo_id => "4d2657e9cc8cb46033000006").first.id
|
||||
end
|
||||
end
|
||||
end
|
||||
describe "#import_raw" do
|
||||
|
|
|
|||
Loading…
Reference in a new issue