It turns out comments weren't importing because I didn't write the code to make them import.
This commit is contained in:
parent
f2a27ea970
commit
300e055933
2 changed files with 51 additions and 0 deletions
|
|
@ -34,6 +34,7 @@ module DataConversion
|
|||
process_raw_requests
|
||||
process_raw_profiles
|
||||
process_raw_posts
|
||||
process_raw_comments
|
||||
process_raw_post_visibilities
|
||||
process_raw_notifications
|
||||
end
|
||||
|
|
@ -227,6 +228,26 @@ module DataConversion
|
|||
SQL
|
||||
log "Imported #{Service.count} services."
|
||||
end
|
||||
def process_raw_comments
|
||||
log "Importing comments to main table..."
|
||||
Comment.connection.execute <<-SQL
|
||||
INSERT INTO comments
|
||||
SELECT mongo_comments.id,
|
||||
mongo_comments.text,
|
||||
posts.id,
|
||||
people.id,
|
||||
mongo_comments.guid,
|
||||
mongo_comments.creator_signature,
|
||||
mongo_comments.post_creator_signature,
|
||||
mongo_comments.youtube_titles,
|
||||
mongo_comments.created_at,
|
||||
mongo_comments.updated_at,
|
||||
mongo_comments.mongo_id
|
||||
FROM mongo_comments INNER JOIN (posts, people)
|
||||
ON (posts.mongo_id = mongo_comments.post_mongo_id AND people.mongo_id = mongo_comments.person_mongo_id)
|
||||
SQL
|
||||
log "Imported #{Comment.count} comments."
|
||||
end
|
||||
def process_raw_people
|
||||
log "Importing people to main table..."
|
||||
Person.connection.execute <<-SQL
|
||||
|
|
|
|||
|
|
@ -367,6 +367,36 @@ describe DataConversion::ImportToMysql do
|
|||
post.updated_at.should == mongo_post.updated_at
|
||||
end
|
||||
end
|
||||
describe "comments" do
|
||||
before do
|
||||
import_and_process("users")
|
||||
import_and_process("people")
|
||||
import_and_process("posts")
|
||||
copy_fixture_for("comments")
|
||||
@migrator.import_raw_comments
|
||||
end
|
||||
|
||||
it "imports data into the mongo_comments table" do
|
||||
Mongo::Comment.count.should == 2
|
||||
Comment.count.should == 0
|
||||
@migrator.process_raw_comments
|
||||
Comment.count.should == 2
|
||||
end
|
||||
|
||||
it "processes all the columns" do
|
||||
@migrator.process_raw_comments
|
||||
comment = Comment.first
|
||||
comment.mongo_id.should == "4d2b6ebfcc8cb43cc200002b"
|
||||
comment.text.should == "Hey me!"
|
||||
comment.youtube_titles.should be_nil
|
||||
end
|
||||
it 'sets the relations' do
|
||||
@migrator.process_raw_comments
|
||||
comment = Comment.first
|
||||
comment.post_id.should == Post.where(:mongo_id => "4d2b6ebecc8cb43cc2000029").first.id
|
||||
comment.person_id.should == Person.where(:mongo_id => "4d2b6eb7cc8cb43cc2000017").first.id
|
||||
end
|
||||
end
|
||||
describe "notifications" do
|
||||
before do
|
||||
import_and_process("users")
|
||||
|
|
|
|||
Loading…
Reference in a new issue