v0.51 Fix mysql bug
This commit is contained in:
parent
e9750621bc
commit
78749e28fc
@ -1,7 +1,7 @@
|
||||
# Federated Computer, Inc.
|
||||
# David Sainty <saint@federated.computer> 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'])
|
||||
|
Loading…
Reference in New Issue
Block a user