mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
correct closing logic for wd importer
This commit is contained in:
parent
7b8b96446e
commit
64bbf2c1c4
@ -62,8 +62,8 @@ class ImportScripts::Lithium < ImportScripts::Base
|
|||||||
import_likes
|
import_likes
|
||||||
import_accepted_answers
|
import_accepted_answers
|
||||||
import_pms
|
import_pms
|
||||||
|
close_topics
|
||||||
|
|
||||||
# close_topics
|
|
||||||
post_process_posts
|
post_process_posts
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -638,35 +638,26 @@ class ImportScripts::Lithium < ImportScripts::Base
|
|||||||
|
|
||||||
def close_topics
|
def close_topics
|
||||||
|
|
||||||
return "NOT WORKING CAUSE NO WAY TO FIND OUT"
|
|
||||||
|
|
||||||
# puts "\nclosing closed topics..."
|
puts "\nclosing closed topics..."
|
||||||
#
|
|
||||||
# sql = "select unique_id post_id from message2 where (attributes & 0x20000000 ) != 0;"
|
sql = "select unique_id post_id from message2 where root_id = id AND (attributes & 0x0002 ) != 0;"
|
||||||
# results = mysql_query(sql)
|
results = mysql_query(sql)
|
||||||
#
|
|
||||||
# # loading post map
|
# loading post map
|
||||||
# existing_map = {}
|
existing_map = {}
|
||||||
# PostCustomField.where(name: 'import_unique_id').pluck(:post_id, :value).each do |post_id, import_id|
|
PostCustomField.where(name: 'import_unique_id').pluck(:post_id, :value).each do |post_id, import_id|
|
||||||
# existing_map[import_id] = post_id
|
existing_map[import_id.to_i] = post_id.to_i
|
||||||
# end
|
end
|
||||||
#
|
|
||||||
# puts "loading data into temp table"
|
results.map{|r| r["post_id"]}.each_slice(500) do |ids|
|
||||||
# PostAction.transaction do
|
mapped = ids.map{|id| existing_map[id]}.compact
|
||||||
# results.each do |result|
|
Topic.exec_sql("
|
||||||
#
|
UPDATE topics SET closed = true
|
||||||
#
|
WHERE id IN (SELECT topic_id FROM posts where id in (:ids))
|
||||||
# p existing_map[result["post_id"].to_s]
|
", ids: mapped) if mapped.present?
|
||||||
#
|
end
|
||||||
# end
|
|
||||||
# end
|
|
||||||
#
|
|
||||||
# exit
|
|
||||||
#
|
|
||||||
# puts "\nfreezing frozen topics..."
|
|
||||||
#
|
|
||||||
# sql = "select unique_id post_id from message2 where (attributes & 0x2000000 ) != 0;"
|
|
||||||
# results = mysql_query(sql)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user