v0.45 SQLIte mutexes only wrap around updates now
This commit is contained in:
parent
90a2d2fa37
commit
0372db9cc7
@ -1,7 +1,7 @@
|
|||||||
# Federated Computer, Inc.
|
# Federated Computer, Inc.
|
||||||
# David Sainty <saint@federated.computer> 2024 A.D.
|
# David Sainty <saint@federated.computer> 2024 A.D.
|
||||||
# Gossamer Threads to Discourse -- Migration-Import Script
|
# Gossamer Threads to Discourse -- Migration-Import Script
|
||||||
# v0.44 Try removing connection_pool and starting MySQL within thread method and fix handle_post_attachment
|
# v0.45 SQLIte mutexes only wrap around updates now
|
||||||
|
|
||||||
require 'mysql2'
|
require 'mysql2'
|
||||||
require 'open-uri'
|
require 'open-uri'
|
||||||
@ -1311,9 +1311,9 @@ class GossamerForumsImporter < ImportScripts::Base
|
|||||||
puts "CREATE TOPIC POST topic.id #{topic.id} discourse_user_id #{discourse_user_id}"
|
puts "CREATE TOPIC POST topic.id #{topic.id} discourse_user_id #{discourse_user_id}"
|
||||||
|
|
||||||
post_number = 0
|
post_number = 0
|
||||||
|
# Increment the post count for the topic
|
||||||
|
post_number = fetch_db_topic_post_numbers(topic.id).to_i + 1
|
||||||
sqlite_mutex.synchronize do
|
sqlite_mutex.synchronize do
|
||||||
# Increment the post count for the topic
|
|
||||||
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)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -1361,28 +1361,28 @@ class GossamerForumsImporter < ImportScripts::Base
|
|||||||
|
|
||||||
puts "CREATE REPLY in topic_id #{topic.id}"
|
puts "CREATE REPLY in topic_id #{topic.id}"
|
||||||
|
|
||||||
|
# Increment the post count for the topic
|
||||||
|
post_number = fetch_db_topic_post_numbers(topic.id).to_i + 1
|
||||||
sqlite_mutex.synchronize do
|
sqlite_mutex.synchronize do
|
||||||
# Increment the post count for the topic
|
|
||||||
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)
|
||||||
|
end
|
||||||
|
|
||||||
# Fetch the number of views the post has had
|
# Fetch the number of views the post has had
|
||||||
reply_post_views = fetch_post_views(reply_row['post_id'])
|
reply_post_views = fetch_post_views(reply_row['post_id'])
|
||||||
|
|
||||||
puts "TIJ JJ post_id #{post_id}"
|
puts "TIJ JJ post_id #{post_id}"
|
||||||
# Create the reply post in the existing topic
|
# Create the reply post in the existing topic
|
||||||
post = Post.create!(
|
post = Post.create!(
|
||||||
topic_id: topic.id,
|
topic_id: topic.id,
|
||||||
user_id: reply_user_id,
|
user_id: reply_user_id,
|
||||||
raw: sanitized_reply_message,
|
raw: sanitized_reply_message,
|
||||||
created_at: Time.at(reply_row['post_time']),
|
created_at: Time.at(reply_row['post_time']),
|
||||||
updated_at: Time.at(reply_row['post_time']),
|
updated_at: Time.at(reply_row['post_time']),
|
||||||
reads: reply_post_views || 0,
|
reads: reply_post_views || 0,
|
||||||
post_number: post_number
|
post_number: post_number
|
||||||
)
|
)
|
||||||
post.custom_fields['original_gossamer_id'] = reply_row['post_id']
|
post.custom_fields['original_gossamer_id'] = reply_row['post_id']
|
||||||
post.save!
|
post.save!
|
||||||
end
|
|
||||||
|
|
||||||
puts "TIJ KK post_id #{post_id}"
|
puts "TIJ KK post_id #{post_id}"
|
||||||
# Increment the post count for the topic and user
|
# Increment the post count for the topic and user
|
||||||
|
Loading…
Reference in New Issue
Block a user