v0.42.1 Rewrite and simplication of concurrent-ruby support

This commit is contained in:
David Sainty 2024-08-17 22:29:49 +10:00
parent 678012f76a
commit fed7a8935e

View File

@ -1138,7 +1138,7 @@ class GossamerForumsImporter < ImportScripts::Base
if post_status.nil? || post_status == 0 if post_status.nil? || post_status == 0
puts "Starting import for post_id #{post_id}" puts "Starting import for post_id #{post_id}"
topic_import_job(post_id, mysql_client, sqlite_mutex) # Import topic and its replies topic_import_job(post_id, mysql_client, sqlite_mutex) # Import topic and its replies
sqlite_mutex.sychronize do sqlite_mutex.synchronize do
mark_post_as_complete(post_id) # Mark as complete in SQLite table mark_post_as_complete(post_id) # Mark as complete in SQLite table
end end
else else
@ -1147,7 +1147,7 @@ class GossamerForumsImporter < ImportScripts::Base
end end
rescue => e rescue => e
puts "Error processing post ID #{post_id}: #{e.message}" puts "Error processing post ID #{post_id}: #{e.message}"
sqlite_mutex.sychronize do sqlite_mutex.synchronize do
mark_post_as_failed(post_id) mark_post_as_failed(post_id)
end end
ensure ensure
@ -1250,7 +1250,7 @@ class GossamerForumsImporter < ImportScripts::Base
end end
end end
sqlite_mutex.sychronize do sqlite_mutex.synchronize do
# Update the database with the last post time and user for the topic # Update the database with the last post time and user for the topic
update_db_topic_last_post_time(topic.id, Time.at(row['post_time']).to_i) update_db_topic_last_post_time(topic.id, Time.at(row['post_time']).to_i)
update_db_topic_last_post_user(topic.id, discourse_user_id) update_db_topic_last_post_user(topic.id, discourse_user_id)
@ -1285,7 +1285,7 @@ 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!
sqlite_mutex.sychronize do sqlite_mutex.synchronize do
# Increment the post count for the topic and user # 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_topic_post_count(topic.id, fetch_db_topic_post_count(topic.id).to_i + 1)
update_db_user_post_count(discourse_user_id, fetch_db_user_post_count(discourse_user_id).to_i + 1) update_db_user_post_count(discourse_user_id, fetch_db_user_post_count(discourse_user_id).to_i + 1)
@ -1314,7 +1314,7 @@ class GossamerForumsImporter < ImportScripts::Base
puts "CREATE REPLY in topic_id #{topic.id}" puts "CREATE REPLY in topic_id #{topic.id}"
sqlite_mutex.sychronize do sqlite_mutex.synchronize do
# Increment the post count for the topic # Increment the post count for the topic
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) update_db_topic_post_numbers(topic.id, post_number)