Bulk import likes from vBulletin thanks (#5014)

This commit is contained in:
Quangbuu Le
2017-08-01 15:01:45 +07:00
committed by Régis Hanol
parent 7ee861f457
commit bac21d317b
2 changed files with 52 additions and 0 deletions

View File

@@ -93,6 +93,8 @@ class BulkImport::VBulletin < BulkImport::Base
import_topics
import_posts
import_likes
import_private_topics
import_topic_allowed_users
import_private_posts
@@ -383,6 +385,36 @@ class BulkImport::VBulletin < BulkImport::Base
end
end
def import_likes
return unless @has_post_thanks
puts "Importing likes..."
@imported_likes = Set.new
@last_imported_post_id = 0
post_thanks = mysql_stream <<-SQL
SELECT postid, userid, date
FROM post_thanks
WHERE postid > #{@last_imported_post_id}
ORDER BY postid
SQL
create_post_actions(post_thanks) do |row|
post_id = post_id_from_imported_id(row[0])
user_id = user_id_from_imported_id(row[1])
next if post_id.nil? || user_id.nil?
next if @imported_likes.add?([post_id, user_id]).nil?
{
post_id: post_id_from_imported_id(row[0]),
user_id: user_id_from_imported_id(row[1]),
post_action_type_id: 2,
created_at: Time.zone.at(row[2])
}
end
end
def import_private_topics
puts "Importing private topics..."