Add contact raw import, fixtures have no comments
This commit is contained in:
parent
e4ef2641f8
commit
b34acfd4eb
5 changed files with 111 additions and 1 deletions
|
|
@ -6,4 +6,6 @@ module Mongo
|
|||
class User < ActiveRecord::Base; end
|
||||
class Aspect < ActiveRecord::Base; end
|
||||
class AspectMembership < ActiveRecord::Base; end
|
||||
class Comment < ActiveRecord::Base; end
|
||||
class Contact < ActiveRecord::Base; end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -16,6 +16,30 @@ class CreateImportTables < ActiveRecord::Migration
|
|||
add_index :mongo_aspect_memberships, :aspect_mongo_id
|
||||
add_index :mongo_aspect_memberships, :contact_mongo_id
|
||||
|
||||
create_table :mongo_comments do |t|
|
||||
t.text :text
|
||||
t.string :mongo_id
|
||||
t.string :post_mongo_id
|
||||
t.string :person_mongo_id
|
||||
t.string :guid
|
||||
t.text :creator_signature
|
||||
t.text :post_creator_signature
|
||||
t.text :youtube_titles
|
||||
t.timestamps
|
||||
end
|
||||
add_index :mongo_comments, :guid, :unique => true
|
||||
add_index :mongo_comments, :post_mongo_id
|
||||
|
||||
create_table :mongo_contacts do |t|
|
||||
t.string :mongo_id
|
||||
t.string :user_mongo_id
|
||||
t.string :person_mongo_id
|
||||
t.boolean :pending, :default => true
|
||||
t.timestamps
|
||||
end
|
||||
add_index :mongo_contacts, [:user_mongo_id, :pending]
|
||||
add_index :mongo_contacts, [:person_mongo_id, :pending]
|
||||
|
||||
create_table :mongo_users do |t|
|
||||
t.string :mongo_id
|
||||
t.string :username
|
||||
|
|
|
|||
28
db/schema.rb
28
db/schema.rb
|
|
@ -90,6 +90,34 @@ ActiveRecord::Schema.define(:version => 20110105051803) do
|
|||
|
||||
add_index "mongo_aspects", ["user_mongo_id"], :name => "index_mongo_aspects_on_user_mongo_id"
|
||||
|
||||
create_table "mongo_comments", :force => true do |t|
|
||||
t.text "text"
|
||||
t.string "mongo_id"
|
||||
t.string "post_mongo_id"
|
||||
t.string "person_mongo_id"
|
||||
t.string "guid"
|
||||
t.text "creator_signature"
|
||||
t.text "post_creator_signature"
|
||||
t.text "youtube_titles"
|
||||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
end
|
||||
|
||||
add_index "mongo_comments", ["guid"], :name => "index_mongo_comments_on_guid", :unique => true
|
||||
add_index "mongo_comments", ["post_mongo_id"], :name => "index_mongo_comments_on_post_mongo_id"
|
||||
|
||||
create_table "mongo_contacts", :force => true do |t|
|
||||
t.string "mongo_id"
|
||||
t.string "user_mongo_id"
|
||||
t.string "person_mongo_id"
|
||||
t.boolean "pending", :default => true
|
||||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
end
|
||||
|
||||
add_index "mongo_contacts", ["person_mongo_id", "pending"], :name => "index_mongo_contacts_on_person_mongo_id_and_pending"
|
||||
add_index "mongo_contacts", ["user_mongo_id", "pending"], :name => "index_mongo_contacts_on_user_mongo_id_and_pending"
|
||||
|
||||
create_table "mongo_users", :force => true do |t|
|
||||
t.string "mongo_id"
|
||||
t.string "username"
|
||||
|
|
|
|||
|
|
@ -39,6 +39,21 @@ OPTS
|
|||
(contact_mongo_id, aspect_mongo_id)
|
||||
SQL
|
||||
end
|
||||
def import_raw_comments
|
||||
Mongo::Aspect.connection.execute <<-SQL
|
||||
#{load_string("comments")}
|
||||
#{infile_opts}
|
||||
(mongo_id, post_mongo_id, person_mongo_id, @diaspora_handle, text, youtube_titles)
|
||||
SET guid = mongo_id;
|
||||
SQL
|
||||
end
|
||||
def import_raw_contacts
|
||||
Mongo::Aspect.connection.execute <<-SQL
|
||||
#{load_string("contacts")}
|
||||
#{infile_opts}
|
||||
(mongo_id, user_mongo_id, person_mongo_id, pending, created_at, updated_at)
|
||||
SQL
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ describe DataConversion::ImportToMysql do
|
|||
copy_fixture_for("aspect_memberships")
|
||||
end
|
||||
|
||||
it "imports data into the mongo_aspects table" do
|
||||
it "imports data into the mongo_aspect_memberships table" do
|
||||
Mongo::AspectMembership.count.should == 0
|
||||
@migrator.import_raw_aspect_memberships
|
||||
Mongo::AspectMembership.count.should == 17
|
||||
|
|
@ -57,6 +57,47 @@ describe DataConversion::ImportToMysql do
|
|||
aspectm.aspect_mongo_id.should =="4d0916c2cc8cb40e93000004"
|
||||
end
|
||||
end
|
||||
|
||||
describe "comments" do
|
||||
before do
|
||||
copy_fixture_for("comments")
|
||||
end
|
||||
|
||||
it "imports data into the mongo_comments table" do
|
||||
Mongo::Comment.count.should == 0
|
||||
@migrator.import_raw_comments
|
||||
Mongo::Comment.count.should == 5
|
||||
end
|
||||
|
||||
it "imports all the columns" do
|
||||
@migrator.import_raw_comments
|
||||
comment = Mongo::Comment.first
|
||||
comment.text.should_not be_nil
|
||||
comment.person_mongo_id.should_not be_nil
|
||||
comment.post_mongo_id.should_not be_nil
|
||||
end
|
||||
end
|
||||
describe "contacts" do
|
||||
before do
|
||||
copy_fixture_for("contacts")
|
||||
end
|
||||
|
||||
it "imports data into the mongo_contacts table" do
|
||||
Mongo::Contact.count.should == 0
|
||||
@migrator.import_raw_contacts
|
||||
Mongo::Contact.count.should == 16
|
||||
end
|
||||
|
||||
it "imports all the columns" do
|
||||
@migrator.import_raw_contacts
|
||||
contact = Mongo::Contact.first
|
||||
contact.mongo_id.should == "4d0916c4cc8cb40e9300000a"
|
||||
contact.user_mongo_id.should =="4d0916c1cc8cb40e93000002"
|
||||
contact.person_mongo_id.should == "4d0916c3cc8cb40e93000007"
|
||||
contact.pending.should be_false
|
||||
contact.created_at.should be_nil
|
||||
end
|
||||
end
|
||||
describe "users" do
|
||||
before do
|
||||
copy_fixture_for("users")
|
||||
|
|
|
|||
Loading…
Reference in a new issue