v0.59 Final topic-post import run -- add logic for appending counts since we are adding to a live Discourse host now
This commit is contained in:
parent
7bd8f0068a
commit
a39e435ffe
BIN
.gossamer_forums.rb.swo
Normal file
BIN
.gossamer_forums.rb.swo
Normal file
Binary file not shown.
Binary file not shown.
@ -1572,7 +1572,7 @@ class GossamerForumsImporter < ImportScripts::Base
|
|||||||
# next if post_id < highest_old_post_id
|
# next if post_id < highest_old_post_id
|
||||||
next if post_id <= highest_processed_post_id
|
next if post_id <= highest_processed_post_id
|
||||||
|
|
||||||
puts "Processing post_id #{row['post_id']} post_id #{row['post_root_id']} post_subject/title #{row['post_subject']} forum_id_fk/category_id #{row['forum_id_fk']}"
|
puts "Processing post_id #{row['post_id']} post_root_id #{row['post_root_id']} post_subject/title #{row['post_subject']} forum_id_fk (category_id) #{row['forum_id_fk']}"
|
||||||
# discourse_user_id = @user_id_map[row['user_id_fk']]
|
# discourse_user_id = @user_id_map[row['user_id_fk']]
|
||||||
|
|
||||||
# Fetch the Discourse user_id based on Gossamer data and mapping
|
# Fetch the Discourse user_id based on Gossamer data and mapping
|
||||||
@ -1731,13 +1731,15 @@ class GossamerForumsImporter < ImportScripts::Base
|
|||||||
# Sanitize the post message
|
# Sanitize the post message
|
||||||
sanitized_post_message = sanitize_post_message(row['post_message'])
|
sanitized_post_message = sanitize_post_message(row['post_message'])
|
||||||
|
|
||||||
puts "CREATE REPLY in topic_id #{topic_id} for reply post_id #{row['post_id']}"
|
|
||||||
|
|
||||||
# topic_post_numbers[topic_id] += 1
|
# topic_post_numbers[topic_id] += 1
|
||||||
post_number = fetch_db_topic_post_numbers(topic_id).to_i + 1
|
post_number = fetch_db_topic_post_numbers(topic_id).to_i + 1
|
||||||
update_db_topic_post_numbers(topic_id, post_number)
|
|
||||||
|
puts "CREATE REPLY in topic_id #{topic_id} for reply post_id #{row['post_id']} with post_number #{post_number}"
|
||||||
|
|
||||||
# Create the post in the existing topic
|
# Create the post in the existing topic
|
||||||
|
post_created = false
|
||||||
|
while ! post_created
|
||||||
|
begin
|
||||||
post = Post.create!(
|
post = Post.create!(
|
||||||
topic_id: topic_id,
|
topic_id: topic_id,
|
||||||
user_id: discourse_user_id,
|
user_id: discourse_user_id,
|
||||||
@ -1755,6 +1757,19 @@ class GossamerForumsImporter < ImportScripts::Base
|
|||||||
post.custom_fields['original_gossamer_id'] = row['post_id']
|
post.custom_fields['original_gossamer_id'] = row['post_id']
|
||||||
post.save!
|
post.save!
|
||||||
|
|
||||||
|
post_created = true
|
||||||
|
|
||||||
|
rescue ActiveRecord::RecordNotUnique => e
|
||||||
|
if e.message.include?("duplicate key value violates unique constraint")
|
||||||
|
post_number = post_number + 1
|
||||||
|
else
|
||||||
|
raise e
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
update_db_topic_post_numbers(topic_id, post_number)
|
||||||
|
|
||||||
# Track the number of posts in the topic and by the user
|
# Track the number of posts in the topic and by the user
|
||||||
# topic_post_count[topic_id] += 1
|
# topic_post_count[topic_id] += 1
|
||||||
# user_post_count[discourse_user_id] += 1
|
# user_post_count[discourse_user_id] += 1
|
||||||
|
Loading…
Reference in New Issue
Block a user