v0.51 Fix mysql bug
This commit is contained in:
parent
e9750621bc
commit
78749e28fc
@ -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.49 Work on Mysql brokenness
|
# v0.51 Fix mysql bug
|
||||||
|
|
||||||
require 'mysql2'
|
require 'mysql2'
|
||||||
require 'open-uri'
|
require 'open-uri'
|
||||||
@ -1076,8 +1076,8 @@ class GossamerForumsImporter < ImportScripts::Base
|
|||||||
end
|
end
|
||||||
|
|
||||||
# Fetch post views from the gforum_PostView table
|
# Fetch post views from the gforum_PostView table
|
||||||
def fetch_post_views(post_id)
|
def fetch_post_views(post_id, mysql_client)
|
||||||
result = execute_query("SELECT post_views FROM gforum_PostView WHERE post_id_fk = #{post_id} LIMIT 1").first
|
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
|
result ? result['post_views'] : 0
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -1301,7 +1301,7 @@ class GossamerForumsImporter < ImportScripts::Base
|
|||||||
unique_title = title
|
unique_title = title
|
||||||
|
|
||||||
# Fetch the number of views the post has had
|
# 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'
|
# 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'])
|
unless TopicCustomField.exists?(name: 'original_gossamer_id', value: row['post_id'])
|
||||||
@ -1429,7 +1429,7 @@ class GossamerForumsImporter < ImportScripts::Base
|
|||||||
end
|
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'], mysql_client)
|
||||||
|
|
||||||
# crazy sanity check
|
# crazy sanity check
|
||||||
if topic.nil?
|
if topic.nil?
|
||||||
@ -1544,7 +1544,7 @@ class GossamerForumsImporter < ImportScripts::Base
|
|||||||
unique_title = title
|
unique_title = title
|
||||||
|
|
||||||
# Confirm the number of views the post has had
|
# 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
|
# Skip if the topic already exists
|
||||||
unless TopicCustomField.exists?(name: 'original_gossamer_id', value: row['post_id'])
|
unless TopicCustomField.exists?(name: 'original_gossamer_id', value: row['post_id'])
|
||||||
@ -1654,7 +1654,7 @@ class GossamerForumsImporter < ImportScripts::Base
|
|||||||
puts "#3"
|
puts "#3"
|
||||||
|
|
||||||
# Confirm the number of views the post has had
|
# 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
|
# Find the root topic for the post
|
||||||
root_topic_field = TopicCustomField.find_by(name: 'original_gossamer_id', value: row['post_root_id'])
|
root_topic_field = TopicCustomField.find_by(name: 'original_gossamer_id', value: row['post_root_id'])
|
||||||
|
Loading…
Reference in New Issue
Block a user