mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
Merge pull request #4604 from mabras/fix-close-topics-vb4-importer
Fix: close topics for vb4 importer
This commit is contained in:
commit
d6981fa77f
@ -227,9 +227,6 @@ class ImportScripts::VBulletin < ImportScripts::Base
|
|||||||
def import_topics
|
def import_topics
|
||||||
puts "", "importing topics..."
|
puts "", "importing topics..."
|
||||||
|
|
||||||
# keep track of closed topics
|
|
||||||
@closed_topic_ids = []
|
|
||||||
|
|
||||||
topic_count = mysql_query("SELECT COUNT(threadid) count FROM #{TABLE_PREFIX}thread").first["count"]
|
topic_count = mysql_query("SELECT COUNT(threadid) count FROM #{TABLE_PREFIX}thread").first["count"]
|
||||||
|
|
||||||
batches(BATCH_SIZE) do |offset|
|
batches(BATCH_SIZE) do |offset|
|
||||||
@ -250,7 +247,6 @@ class ImportScripts::VBulletin < ImportScripts::Base
|
|||||||
raw = preprocess_post_raw(topic["raw"]) rescue nil
|
raw = preprocess_post_raw(topic["raw"]) rescue nil
|
||||||
next if raw.blank?
|
next if raw.blank?
|
||||||
topic_id = "thread-#{topic["threadid"]}"
|
topic_id = "thread-#{topic["threadid"]}"
|
||||||
@closed_topic_ids << topic_id if topic["open"] == 0
|
|
||||||
t = {
|
t = {
|
||||||
id: topic_id,
|
id: topic_id,
|
||||||
user_id: user_id_from_imported_user_id(topic["postuserid"]) || Discourse::SYSTEM_USER_ID,
|
user_id: user_id_from_imported_user_id(topic["postuserid"]) || Discourse::SYSTEM_USER_ID,
|
||||||
@ -509,6 +505,20 @@ class ImportScripts::VBulletin < ImportScripts::Base
|
|||||||
def close_topics
|
def close_topics
|
||||||
puts "", "Closing topics..."
|
puts "", "Closing topics..."
|
||||||
|
|
||||||
|
# keep track of closed topics
|
||||||
|
closed_topic_ids = []
|
||||||
|
|
||||||
|
topics = mysql_query <<-MYSQL
|
||||||
|
SELECT t.threadid threadid, firstpostid, open
|
||||||
|
FROM #{TABLE_PREFIX}thread t
|
||||||
|
JOIN #{TABLE_PREFIX}post p ON p.postid = t.firstpostid
|
||||||
|
ORDER BY t.threadid
|
||||||
|
MYSQL
|
||||||
|
topics.each do |topic|
|
||||||
|
topic_id = "thread-#{topic["threadid"]}"
|
||||||
|
closed_topic_ids << topic_id if topic["open"] == 0
|
||||||
|
end
|
||||||
|
|
||||||
sql = <<-SQL
|
sql = <<-SQL
|
||||||
WITH closed_topic_ids AS (
|
WITH closed_topic_ids AS (
|
||||||
SELECT t.id AS topic_id
|
SELECT t.id AS topic_id
|
||||||
@ -523,7 +533,7 @@ class ImportScripts::VBulletin < ImportScripts::Base
|
|||||||
WHERE id IN (SELECT topic_id FROM closed_topic_ids)
|
WHERE id IN (SELECT topic_id FROM closed_topic_ids)
|
||||||
SQL
|
SQL
|
||||||
|
|
||||||
Topic.exec_sql(sql, @closed_topic_ids)
|
Topic.exec_sql(sql, closed_topic_ids)
|
||||||
end
|
end
|
||||||
|
|
||||||
def post_process_posts
|
def post_process_posts
|
||||||
|
Loading…
Reference in New Issue
Block a user