v0.29 Final tweak for personal msg import for now; prep for migration cont
This commit is contained in:
		@@ -1,5 +1,5 @@
 | 
				
			|||||||
# gossamer threads migration-import code
 | 
					# gossamer threads migration-import code
 | 
				
			||||||
# v0.28.1
 | 
					# v0.29
 | 
				
			||||||
 | 
					
 | 
				
			||||||
require 'mysql2'
 | 
					require 'mysql2'
 | 
				
			||||||
require 'open-uri'
 | 
					require 'open-uri'
 | 
				
			||||||
@@ -1160,17 +1160,18 @@ class GossamerForumsImporter < ImportScripts::Base
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  # Import personal messages from gforum_Message table (both inbox and sent messages)
 | 
					  # Import personal messages from gforum_Message table (both inbox and sent messages)
 | 
				
			||||||
  def import_personal_messages
 | 
					  def import_personal_messages
 | 
				
			||||||
    puts "Importing personal (inbox and sendmail) messages..."
 | 
					    puts "Importing personal (inbox and sentmail) messages..."
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # Fetch the highest_processed_personal_id
 | 
					    # Fetch the highest_processed_personal_id
 | 
				
			||||||
    highest_processed_personal_id = fetch_highest_processed_personal_id.to_i
 | 
					    highest_processed_personal_id = fetch_highest_processed_personal_id.to_i
 | 
				
			||||||
    puts "Highest processed personal_id: #{highest_processed_personal_id}"
 | 
					    puts "Highest processed personal_id: #{highest_processed_personal_id}"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# OVERRIDE - to get to problem msg
 | 
					# OVERRIDE - to speed getting to problem msg
 | 
				
			||||||
    highest_processed_personal_id = 350
 | 
					#    highest_processed_personal_id = 350
 | 
				
			||||||
    puts "Highest processed personal_id override: #{highest_processed_personal_id}"
 | 
					    puts "Highest processed personal_id override: #{highest_processed_personal_id}"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    execute_query("SELECT * FROM gforum_Message").each do |row|
 | 
					    execute_query("SELECT * FROM gforum_Message").each do |row|
 | 
				
			||||||
 | 
					      begin
 | 
				
			||||||
        msg_id = row['msg_id'].to_i
 | 
					        msg_id = row['msg_id'].to_i
 | 
				
			||||||
        puts "msg_id  #{msg_id}"
 | 
					        puts "msg_id  #{msg_id}"
 | 
				
			||||||
  
 | 
					  
 | 
				
			||||||
@@ -1189,7 +1190,7 @@ class GossamerForumsImporter < ImportScripts::Base
 | 
				
			|||||||
          sanitized_message = sanitize_post_message(row['msg_body'])
 | 
					          sanitized_message = sanitize_post_message(row['msg_body'])
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
          # Set default message body if the sanitized message is blank
 | 
					          # Set default message body if the sanitized message is blank
 | 
				
			||||||
        sanitized_message = "<no message body>" if sanitized_message.strip.empty?
 | 
					          sanitized_message = "<No message body to migrate.>" if sanitized_message.strip.empty? || sanitized_message.split.size < 3
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
          # If we do not change the "min personal message post length" to 1, we need this. ... We may need this anyway.
 | 
					          # If we do not change the "min personal message post length" to 1, we need this. ... We may need this anyway.
 | 
				
			||||||
          sanitized_message = sanitized_message.ljust(10, '.') if sanitized_message.length < 10
 | 
					          sanitized_message = sanitized_message.ljust(10, '.') if sanitized_message.length < 10
 | 
				
			||||||
@@ -1198,7 +1199,7 @@ class GossamerForumsImporter < ImportScripts::Base
 | 
				
			|||||||
          sanitized_title = row['msg_subject']&.strip
 | 
					          sanitized_title = row['msg_subject']&.strip
 | 
				
			||||||
          sanitized_title = "<no subject>" if sanitized_title.nil? || sanitized_title.empty?
 | 
					          sanitized_title = "<no subject>" if sanitized_title.nil? || sanitized_title.empty?
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
        puts "IMPORTING msg.  sanitized_title: #{sanitized_title}  orig title: #{row['msg_subject']}  user_id  #{from_user_id}  to_user_id  #{to_user_id}"
 | 
					          puts "IMPORTING msg.  sanitized: #{sanitized_title}  user_id  #{from_user_id}  to_user_id  #{to_user_id}"
 | 
				
			||||||
  
 | 
					  
 | 
				
			||||||
          # Create a private message topic in Discourse
 | 
					          # Create a private message topic in Discourse
 | 
				
			||||||
          topic = Topic.create!(
 | 
					          topic = Topic.create!(
 | 
				
			||||||
@@ -1230,6 +1231,9 @@ class GossamerForumsImporter < ImportScripts::Base
 | 
				
			|||||||
# N/A. These were never a thing in Slowtwitch...  
 | 
					# N/A. These were never a thing in Slowtwitch...  
 | 
				
			||||||
#          handle_post_attachments(row['msg_id'], post, from_user_id)
 | 
					#          handle_post_attachments(row['msg_id'], post, from_user_id)
 | 
				
			||||||
        end
 | 
					        end
 | 
				
			||||||
 | 
					      rescue StandardError => e
 | 
				
			||||||
 | 
					        puts "Error importing message #{row['msg_id']}: #{e.message}"
 | 
				
			||||||
 | 
					      end
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -1250,11 +1254,11 @@ class GossamerForumsImporter < ImportScripts::Base
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
#    import_categories
 | 
					#    import_categories
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#    import_topics_and_posts_with_attachments
 | 
					    import_topics_and_posts_with_attachments
 | 
				
			||||||
#    update_topic_stats
 | 
					    update_topic_stats
 | 
				
			||||||
    update_user_stats
 | 
					    update_user_stats
 | 
				
			||||||
#    export_url_mapping_to_csv("gossamer-migration-url-mapping#{timestamp}")
 | 
					    export_url_mapping_to_csv("gossamer-migration-url-mapping#{timestamp}")
 | 
				
			||||||
#    create_nginx_rewrite_rules("gossamer-redirects#{timestamp}.conf")
 | 
					    create_nginx_rewrite_rules("gossamer-redirects#{timestamp}.conf")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    import_personal_messages
 | 
					    import_personal_messages
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user