diff --git a/gossamer_forums.rb b/gossamer_forums.rb index d7f732a..632a4b9 100644 --- a/gossamer_forums.rb +++ b/gossamer_forums.rb @@ -1,7 +1,7 @@ # Federated Computer, Inc. # David Sainty 2024 A.D. # Gossamer Threads to Discourse -- Migration-Import Script -# v0.49 Work on Mysql brokenness +# v0.51 Fix mysql bug require 'mysql2' require 'open-uri' @@ -1076,8 +1076,8 @@ class GossamerForumsImporter < ImportScripts::Base end # Fetch post views from the gforum_PostView table - def fetch_post_views(post_id) - result = execute_query("SELECT post_views FROM gforum_PostView WHERE post_id_fk = #{post_id} LIMIT 1").first + def fetch_post_views(post_id, mysql_client) + result = execute_query_concurrent("SELECT post_views FROM gforum_PostView WHERE post_id_fk = #{post_id} LIMIT 1", mysql_client).first result ? result['post_views'] : 0 end @@ -1301,7 +1301,7 @@ class GossamerForumsImporter < ImportScripts::Base unique_title = title # Fetch the number of views the post has had - post_views = fetch_post_views(row['post_id']) + post_views = fetch_post_views(row['post_id'], mysql_client) # Check if the topic has already been imported using the custom field 'original_gossamer_id' unless TopicCustomField.exists?(name: 'original_gossamer_id', value: row['post_id']) @@ -1429,7 +1429,7 @@ class GossamerForumsImporter < ImportScripts::Base end # 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'], mysql_client) # crazy sanity check if topic.nil? @@ -1544,7 +1544,7 @@ class GossamerForumsImporter < ImportScripts::Base unique_title = title # Confirm the number of views the post has had - post_views = fetch_post_views(row['post_id']) + post_views = fetch_post_views(row['post_id'], @mysql_client) # Skip if the topic already exists unless TopicCustomField.exists?(name: 'original_gossamer_id', value: row['post_id']) @@ -1654,7 +1654,7 @@ class GossamerForumsImporter < ImportScripts::Base puts "#3" # Confirm the number of views the post has had - post_views = fetch_post_views(row['post_id']) + post_views = fetch_post_views(row['post_id'], @mysql_client) # Find the root topic for the post root_topic_field = TopicCustomField.find_by(name: 'original_gossamer_id', value: row['post_root_id'])