v0.41.2 Several bug fixes and improvements for fully concurrent topic-post import

This commit is contained in:
David Sainty 2024-08-17 19:04:57 +10:00
parent 7faa849198
commit 8f80fbd19f

View File

@ -1275,10 +1275,11 @@ class GossamerForumsImporter < ImportScripts::Base
# Import each reply sequentially
replies.each do |reply_row|
begin
## begin
# Fetch the discourse user ID for the reply
reply_user_id = fetch_user_id_mapping(reply_row['user_id_fk'])
puts "TIJ II post_id #{post_id}"
# Sanitize and prepare the reply message for Discourse
sanitized_reply_message = sanitize_post_message(reply_row['post_message'])
@ -1291,6 +1292,7 @@ class GossamerForumsImporter < ImportScripts::Base
# Fetch the number of views the post has had
reply_post_views = fetch_post_views(reply_row['post_id'])
puts "TIJ JJ post_id #{post_id}"
# Create the reply post in the existing topic
post = Post.create!(
topic_id: topic.id,
@ -1304,6 +1306,7 @@ class GossamerForumsImporter < ImportScripts::Base
post.custom_fields['original_gossamer_id'] = reply_row['post_id']
post.save!
puts "TIJ KK post_id #{post_id}"
# Increment the post count for the topic and user
update_db_topic_post_count(topic.id, fetch_db_topic_post_count(topic.id).to_i + 1)
update_db_user_post_count(reply_user_id, fetch_db_user_post_count(reply_user_id).to_i + 1)
@ -1321,9 +1324,9 @@ class GossamerForumsImporter < ImportScripts::Base
# update_highest_processed_post_id_thread_safe(reply_row['post_id'])
# rescue ActiveRecord::RecordInvalid => e
rescue => e
puts "Error importing reply with post_id #{reply_row['post_id']}: #{e.message}"
end
## rescue => e
## puts "Error importing reply with post_id #{reply_row['post_id']}: #{e.message}"
## end
end
# # After processing the entire topic, update the highest_processed_post_id to the current topic's post_id (thread-safe)