raw import of notifications, failing to pull in unread

This commit is contained in:
Raphael 2011-01-06 14:37:59 -08:00
parent 564dd993b7
commit 7c4d35cf28
5 changed files with 55 additions and 2 deletions

View file

@ -8,7 +8,7 @@ module Mongo
class Comment < ActiveRecord::Base; end
class Contact < ActiveRecord::Base; end
class Invitation < ActiveRecord::Base; end
#class Notification < ActiveRecord::Base; end
class Notification < ActiveRecord::Base; end
class Person < ActiveRecord::Base; end
#Photo?
#Post?

View file

@ -62,7 +62,17 @@ class CreateImportTables < ActiveRecord::Migration
t.timestamps
end
add_index :mongo_invitations, :sender_mongo_id
create_table :mongo_notifications do |t|
t.string :mongo_id
t.string :target_type
t.string :target_mongo_id
t.string :recipient_mongo_id
t.string :actor_mongo_id
t.string :action
t.boolean :unread, :default => true
t.timestamps
end
add_index :mongo_notifications, [:target_type, :target_mongo_id]
create_table :mongo_post_visibilities do |t|
t.string :aspect_mongo_id
t.string :post_mongo_id

View file

@ -130,6 +130,20 @@ ActiveRecord::Schema.define(:version => 20110105051803) do
add_index "mongo_invitations", ["sender_mongo_id"], :name => "index_mongo_invitations_on_sender_mongo_id"
create_table "mongo_notifications", :force => true do |t|
t.string "mongo_id"
t.string "target_type"
t.string "target_mongo_id"
t.string "recipient_mongo_id"
t.string "actor_mongo_id"
t.string "action"
t.boolean "unread", :default => true
t.datetime "created_at"
t.datetime "updated_at"
end
add_index "mongo_notifications", ["target_type", "target_mongo_id"], :name => "index_mongo_notifications_on_target_type_and_target_mongo_id"
create_table "mongo_people", :force => true do |t|
t.string "mongo_id"
t.string "guid"

View file

@ -113,6 +113,15 @@ module DataConversion
SQL
log "Finished. Imported #{Mongo::Invitation.count} invitations."
end
def import_raw_notifications
log "Loading notifications file..."
Mongo::Notification.connection.execute <<-SQL
#{load_string("notifications")}
#{infile_opts}
(mongo_id,target_mongo_id,target_type,unread)
SQL
log "Finished. Imported #{Mongo::Notification.count} notifications."
end
def import_raw_people
log "Loading people file..."
Mongo::Person.connection.execute <<-SQL

View file

@ -122,6 +122,26 @@ describe DataConversion::ImportToMysql do
end
end
describe "notifications" do
before do
copy_fixture_for("notifications")
end
it "imports data into the mongo_notifications table" do
Mongo::Notification.count.should == 0
@migrator.import_raw_notifications
Mongo::Notification.count.should == 3
end
it "imports all the columns" do
@migrator.import_raw_notifications
notification = Mongo::Notification.first
notification.mongo_id.should == "4d26212ccc8cb44df200001c"
notification.target_mongo_id.should == '4d26212ccc8cb44df200001b'
notification.target_type.should == "new_request"
notification.unread.should be_true
end
end
describe "people" do