export more things from mongo
This commit is contained in:
parent
f277fb3bb8
commit
c90f3cb1ef
3 changed files with 33 additions and 4 deletions
|
|
@ -30,8 +30,8 @@ module DataConversion
|
|||
:attrs => ["mongo_id", "recipient_mongo_id", "sender_mongo_id", "aspect_mongo_id", "message"],
|
||||
:mongo_attrs => ["_id" , "to_id" , "from_id" , "into_id" , "message"]},
|
||||
{:name => :notifications,
|
||||
:attrs => ["mongo_id", "target_id", "target_type", "unread"],
|
||||
:mongo_attrs => ["_id" , "target_id", "kind" , "unread"]},
|
||||
:attrs => ["mongo_id", "target_mongo_id", "recipient_mongo_id", "actor_mongo_id", "action", "target_type", "unread"],
|
||||
:mongo_attrs => ["_id" , "target_id" , "recipient_id" , "actor_id" , "action", "kind" , "unread"]},
|
||||
{:name => :people,
|
||||
:attrs => ["created_at", "updated_at", "serialized_public_key", "url", "mongo_id", "owner_mongo_id", "diaspora_handle"],
|
||||
:profile_attrs => ["image_url_medium", "searchable", "image_url", "person_mongo_id", "gender", "diaspora_handle", "birthday", "last_name", "bio", "image_url_small", "first_name"]},
|
||||
|
|
|
|||
|
|
@ -254,10 +254,38 @@ module DataConversion
|
|||
log "Imported #{Person.count} people."
|
||||
end
|
||||
def process_raw_post_visibilities
|
||||
|
||||
log "Importing post_visibilities to main table..."
|
||||
PostVisibility.connection.execute <<-SQL
|
||||
INSERT INTO post_visibilities
|
||||
SELECT mongo_post_visibilities.id,
|
||||
aspects.id,
|
||||
posts.id,
|
||||
mongo_post_visibilities.created_at,
|
||||
mongo_post_visibilities.updated_at
|
||||
FROM mongo_post_visibilities INNER JOIN (aspects, posts)
|
||||
ON (aspects.mongo_id = mongo_post_visibilities.aspect_mongo_id AND posts.mongo_id = mongo_post_visibilities.post_mongo_id)
|
||||
SQL
|
||||
log "Imported #{PostVisibility.count} post_visibilities."
|
||||
end
|
||||
def process_raw_notifications
|
||||
|
||||
log "Importing notifications to main table..."
|
||||
Notification.connection.execute <<-SQL
|
||||
INSERT INTO notifications
|
||||
SELECT m_n.id,
|
||||
m_n.target_type,
|
||||
NULL,
|
||||
users.id,
|
||||
people.id,
|
||||
m_n.action,
|
||||
m_n.unread,
|
||||
m_n.created_at,
|
||||
m_n.updated_at,
|
||||
m_n.mongo_id
|
||||
FROM mongo_notifications AS m_n
|
||||
INNER JOIN (users, people)
|
||||
ON (m_n.recipient_mongo_id = users.mongo_id AND m_n.actor_mongo_id = people.mongo_id)
|
||||
SQL
|
||||
log "Imported #{Notification.count} notifications."
|
||||
end
|
||||
def import_raw_users
|
||||
log "Loading users file..."
|
||||
|
|
|
|||
|
|
@ -380,6 +380,7 @@ describe DataConversion::ImportToMysql do
|
|||
it "imports data into the notifications table" do
|
||||
Mongo::Notification.count.should == 2
|
||||
Notification.count.should == 0
|
||||
debugger
|
||||
@migrator.process_raw_notifications
|
||||
Notification.count.should == 2
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in a new issue