From 894a008daa858a35f7f0d4919b95bde11a76187b Mon Sep 17 00:00:00 2001 From: Raphael Date: Tue, 4 Jan 2011 11:59:25 -0800 Subject: [PATCH] Hopefully finish export to csv --- lib/mongo_to_mysql.rb | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/mongo_to_mysql.rb b/lib/mongo_to_mysql.rb index 00c1c77b1..03b03dcad 100644 --- a/lib/mongo_to_mysql.rb +++ b/lib/mongo_to_mysql.rb @@ -76,9 +76,9 @@ class MongoToMysql csv.close end def comments_json_to_csv model_hash - model_hash[:attrs] = ["mongo_id", "post_mongo_id", "person_mongo_id", "diaspora_handle", "text"] + model_hash[:attrs] = ["mongo_id", "post_mongo_id", "person_mongo_id", "diaspora_handle", "text", "youtube_titles"] generic_json_to_csv(model_hash) do |hash| - [hash["_id"], hash["post_id"], hash["person_id"], hash["diaspora_handle"], hash["text"]] + [hash["_id"], hash["post_id"], hash["person_id"], hash["diaspora_handle"], hash["text"], hash["youtube_titles"]] end end def contacts_json_to_csv model_hash @@ -139,7 +139,11 @@ class MongoToMysql profiles_csv.close end def posts_json_to_csv model_hash - model_hash[:attrs] = ["youtube_titles", "pending", "created_at", "public", "updated_at", "status_message_mongo_id", "caption", "remote_photo_path", "random_string", "image", "mongo_id", "type", "diaspora_handle", "person_mongo_id", "message" ] + model_hash[:attrs] =["youtube_titles", "pending", "created_at", "public", "updated_at", "status_message_mongo_id", "caption", "remote_photo_path", "random_string", "image", "mongo_id", "type", "diaspora_handle", "person_mongo_id", "message" ] + generic_json_to_csv(model_hash) do |hash| + mongo_attrs = ["youtube_titles", "pending", "created_at", "public", "updated_at", "status_message_id", "caption", "remote_photo_path", "random_string", "image", "_id", "_type", "diaspora_handle", "person_id", "message" ] + mongo_attrs.map{|attr_name| hash[attr_name]} + end #has to handle the polymorphic stuff end def requests_json_to_csv model_hash