Set target_id on notifications
This commit is contained in:
parent
30f98aec3c
commit
079151eeea
2 changed files with 16 additions and 3 deletions
|
|
@ -286,6 +286,15 @@ module DataConversion
|
|||
ON (m_n.recipient_mongo_id = users.mongo_id AND m_n.actor_mongo_id = people.mongo_id)
|
||||
SQL
|
||||
log "Imported #{Notification.count} notifications."
|
||||
{"Request" => "requests", "Comment" => "comments"}.each_pair do |target_type, table_name|
|
||||
log "Setting target_id on notifications on #{target_type}"
|
||||
Notification.connection.execute <<-UPDATESQL
|
||||
UPDATE notifications, #{table_name}, mongo_notifications
|
||||
SET notifications.target_id = #{table_name}.id
|
||||
WHERE notifications.mongo_id = mongo_notifications.mongo_id AND #{table_name}.mongo_id = mongo_notifications.target_mongo_id
|
||||
UPDATESQL
|
||||
end
|
||||
log "Done setting target_id"
|
||||
end
|
||||
def import_raw_users
|
||||
log "Loading users file..."
|
||||
|
|
@ -429,11 +438,12 @@ module DataConversion
|
|||
SQL
|
||||
log "Finished. Imported #{Mongo::Notification.count} notifications."
|
||||
{"new_request" => "Request",
|
||||
"request_accepted" => "Contact",
|
||||
"request_accepted" => "Request",
|
||||
"comment_on_post" => "Comment",
|
||||
"also_commented" => "Comment"}.each_pair do |key, value|
|
||||
Mongo::Notification.where(:action => key).update_all(:target_type => value)
|
||||
end
|
||||
log "Notification target types set."
|
||||
end
|
||||
def import_raw_people
|
||||
log "Loading people file..."
|
||||
|
|
|
|||
|
|
@ -373,6 +373,8 @@ describe DataConversion::ImportToMysql do
|
|||
import_and_process("users")
|
||||
import_and_process("people")
|
||||
import_and_process("posts")
|
||||
import_and_process("aspects")
|
||||
import_and_process("requests")
|
||||
copy_fixture_for("notifications")
|
||||
@migrator.import_raw_notifications
|
||||
end
|
||||
|
|
@ -389,9 +391,10 @@ describe DataConversion::ImportToMysql do
|
|||
notification = Notification.first
|
||||
mongo_notification = Mongo::Notification.first
|
||||
notification.mongo_id.should == "4d2b6eb8cc8cb43cc200001f"
|
||||
notification.target.mongo_id.should == mongo_notification.target_mongo_id
|
||||
notification.target_type.should == "new_request"
|
||||
notification.target_type.should == "Request"
|
||||
notification.action.should == "new_request"
|
||||
notification.unread.should be_true
|
||||
notification.target.mongo_id.should == mongo_notification.target_mongo_id
|
||||
end
|
||||
end
|
||||
describe "post_visibilities" do
|
||||
|
|
|
|||
Loading…
Reference in a new issue