allow views to be specified in import mode

This commit is contained in:
Sam 2015-07-16 16:11:20 +10:00
parent bfd28ca9a9
commit 5db345705b
2 changed files with 11 additions and 6 deletions

View File

@ -73,6 +73,10 @@ class TopicCreator
topic_params[key] = @opts[key] if @opts[key].present?
end
if topic_params[:import_mode] && @opts[:views].to_i > 0
topic_params[:views] = @opts[:views].to_i
end
# Automatically give it a moderator warning subtype if specified
topic_params[:subtype] = TopicSubtype.moderator_warning if @opts[:is_warning]

View File

@ -57,7 +57,7 @@ class ImportScripts::Lithium < ImportScripts::Base
# import_attachments
#
# close_topics
# post_process_posts
post_process_posts
end
def import_groups
@ -229,7 +229,7 @@ class ImportScripts::Lithium < ImportScripts::Base
SELECT id, subject, body, deleted, user_id,
post_date, views, node_id, unique_id
FROM message2
WHERE id = root_id #{TEMP} AND deleted = 0
WHERE id = root_id #{TEMP} AND deleted = 0 AND views > 0
ORDER BY node_id, id
LIMIT #{BATCH_SIZE}
OFFSET #{offset}
@ -244,7 +244,7 @@ class ImportScripts::Lithium < ImportScripts::Base
raw = to_markdown(topic["body"])
t = {
{
id: "#{topic["node_id"]} #{topic["id"]}",
user_id: user_id_from_imported_user_id(topic["user_id"]) || Discourse::SYSTEM_USER_ID,
title: @htmlentities.decode(topic["subject"]).strip[0...255],
@ -252,10 +252,10 @@ class ImportScripts::Lithium < ImportScripts::Base
raw: raw,
created_at: unix_time(topic["post_date"]),
views: topic["views"],
custom_fields: {import_unique_id: topic["unique_id"]}
custom_fields: {import_unique_id: topic["unique_id"]},
import_mode: true
}
t
end
end
end
@ -291,7 +291,8 @@ class ImportScripts::Lithium < ImportScripts::Base
topic_id: topic[:topic_id],
raw: raw,
created_at: unix_time(post["post_date"]),
custom_fields: {import_unique_id: post["unique_id"]}
custom_fields: {import_unique_id: post["unique_id"]},
import_mode: true
}
if post["deleted"] > 0