v0.56 Prep to run 20240828 MDT

This commit is contained in:
David Sainty 2024-08-29 01:50:55 +10:00
parent 550da20a89
commit e9612b6f1b

View File

@ -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.55 Exception handling for topic or user entries in SQLite that are no (longer) in the Discourse DB # v0.56 Prep to run 20240828 MDT
require 'mysql2' require 'mysql2'
require 'open-uri' require 'open-uri'
@ -737,16 +737,16 @@ class GossamerForumsImporter < ImportScripts::Base
discourse_user.user_profile.bio_raw ||= "" discourse_user.user_profile.bio_raw ||= ""
# Append bio if it exists, otherwise set it to empty string to avoid nil errors # Append bio if it exists, otherwise set it to empty string to avoid nil errors
if discourse_user.user_profile.bio_raw.empty? ## if discourse_user.user_profile.bio_raw.empty?
discourse_user.user_profile.bio_raw = user[:bio_raw] discourse_user.user_profile.bio_raw = user[:bio_raw]
else ## else
discourse_user.user_profile.bio_raw += "\n\n" + user[:bio_raw] ## discourse_user.user_profile.bio_raw += "\n\n" + user[:bio_raw]
end ## end
# Ensure the bio does not exceed 3000 characters # Ensure the bio does not exceed 3000 characters
if discourse_user.user_profile.bio_raw.length > 3000 if discourse_user.user_profile.bio_raw.length > 2999
puts "Warning: About Me for user #{discourse_user.username} (ID: #{discourse_user.id}) exceeds 3000 characters. Truncating." puts "Warning: About Me for user #{discourse_user.username} (ID: #{discourse_user.id}) exceeds 3000 characters. Truncating."
discourse_user.user_profile.bio_raw = discourse_user.user_profile.bio_raw[0, 3000] discourse_user.user_profile.bio_raw = discourse_user.user_profile.bio_raw[0, 2999]
end end
discourse_user.user_profile.save! discourse_user.user_profile.save!
@ -1994,18 +1994,18 @@ class GossamerForumsImporter < ImportScripts::Base
puts "Starting Gossamer Forums import... #{timestamp}" puts "Starting Gossamer Forums import... #{timestamp}"
# add_former_user add_former_user
# import_users import_users
# generate_user_id_mapping generate_user_id_mapping
export_username_mapping_to_csv("/bitnami/discourse/sqlite/gossamer-migration-username-mapping#{timestamp}") export_username_mapping_to_csv("/bitnami/discourse/sqlite/gossamer-migration-username-mapping#{timestamp}")
# set_user_bio_images # set_user_bio_images
# import_categories import_categories
####### import_topics_and_posts_with_attachments ####### import_topics_and_posts_with_attachments
# threaded_topic_import threaded_topic_import
update_topic_stats update_topic_stats
update_user_stats update_user_stats