allow views to be specified in import mode
This commit is contained in:
parent
bfd28ca9a9
commit
5db345705b
|
@ -73,6 +73,10 @@ class TopicCreator
|
||||||
topic_params[key] = @opts[key] if @opts[key].present?
|
topic_params[key] = @opts[key] if @opts[key].present?
|
||||||
end
|
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
|
# Automatically give it a moderator warning subtype if specified
|
||||||
topic_params[:subtype] = TopicSubtype.moderator_warning if @opts[:is_warning]
|
topic_params[:subtype] = TopicSubtype.moderator_warning if @opts[:is_warning]
|
||||||
|
|
||||||
|
|
|
@ -57,7 +57,7 @@ class ImportScripts::Lithium < ImportScripts::Base
|
||||||
# import_attachments
|
# import_attachments
|
||||||
#
|
#
|
||||||
# close_topics
|
# close_topics
|
||||||
# post_process_posts
|
post_process_posts
|
||||||
end
|
end
|
||||||
|
|
||||||
def import_groups
|
def import_groups
|
||||||
|
@ -229,7 +229,7 @@ class ImportScripts::Lithium < ImportScripts::Base
|
||||||
SELECT id, subject, body, deleted, user_id,
|
SELECT id, subject, body, deleted, user_id,
|
||||||
post_date, views, node_id, unique_id
|
post_date, views, node_id, unique_id
|
||||||
FROM message2
|
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
|
ORDER BY node_id, id
|
||||||
LIMIT #{BATCH_SIZE}
|
LIMIT #{BATCH_SIZE}
|
||||||
OFFSET #{offset}
|
OFFSET #{offset}
|
||||||
|
@ -244,7 +244,7 @@ class ImportScripts::Lithium < ImportScripts::Base
|
||||||
|
|
||||||
raw = to_markdown(topic["body"])
|
raw = to_markdown(topic["body"])
|
||||||
|
|
||||||
t = {
|
{
|
||||||
id: "#{topic["node_id"]} #{topic["id"]}",
|
id: "#{topic["node_id"]} #{topic["id"]}",
|
||||||
user_id: user_id_from_imported_user_id(topic["user_id"]) || Discourse::SYSTEM_USER_ID,
|
user_id: user_id_from_imported_user_id(topic["user_id"]) || Discourse::SYSTEM_USER_ID,
|
||||||
title: @htmlentities.decode(topic["subject"]).strip[0...255],
|
title: @htmlentities.decode(topic["subject"]).strip[0...255],
|
||||||
|
@ -252,10 +252,10 @@ class ImportScripts::Lithium < ImportScripts::Base
|
||||||
raw: raw,
|
raw: raw,
|
||||||
created_at: unix_time(topic["post_date"]),
|
created_at: unix_time(topic["post_date"]),
|
||||||
views: topic["views"],
|
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
|
end
|
||||||
end
|
end
|
||||||
|
@ -291,7 +291,8 @@ class ImportScripts::Lithium < ImportScripts::Base
|
||||||
topic_id: topic[:topic_id],
|
topic_id: topic[:topic_id],
|
||||||
raw: raw,
|
raw: raw,
|
||||||
created_at: unix_time(post["post_date"]),
|
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
|
if post["deleted"] > 0
|
||||||
|
|
Loading…
Reference in New Issue