v0.39.3 Add SQLite table for tracking successful post importation; Split out user import into three separate callable methods; require sys/proctable
This commit is contained in:
parent
5b6f2c3c0e
commit
44d673ffaa
@ -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.39.2 Add SQLite table for tracking successful post importation; Split out user import into three separate callable methods; require sys/proctable
|
# v0.39.3 Add SQLite table for tracking successful post importation; Split out user import into three separate callable methods; require sys/proctable
|
||||||
|
|
||||||
require 'mysql2'
|
require 'mysql2'
|
||||||
require 'open-uri'
|
require 'open-uri'
|
||||||
@ -604,6 +604,28 @@ class GossamerForumsImporter < ImportScripts::Base
|
|||||||
# Generate SQLite user ID mapping between Discourse and Gossamer
|
# Generate SQLite user ID mapping between Discourse and Gossamer
|
||||||
def generate_user_id_mapping
|
def generate_user_id_mapping
|
||||||
puts "Generating User ID Mapping..."
|
puts "Generating User ID Mapping..."
|
||||||
|
users = []
|
||||||
|
|
||||||
|
# Fetch all users from Gossamer Forums
|
||||||
|
execute_query("SELECT * FROM gforum_User").each do |row|
|
||||||
|
users << {
|
||||||
|
id: row['user_id'],
|
||||||
|
username: sanitize_username(row['user_username'], row['user_email'], row['user_real_name']),
|
||||||
|
email: row['user_email'],
|
||||||
|
created_at: Time.at(row['user_registered']),
|
||||||
|
updated_at: Time.at(row['user_last_seen']),
|
||||||
|
name: row['user_real_name'],
|
||||||
|
title: row['user_title'],
|
||||||
|
bio_raw: row['user_about'] || "",
|
||||||
|
website: row['user_homepage'],
|
||||||
|
location: row['user_location'],
|
||||||
|
custom_fields: {
|
||||||
|
md5_password: row['user_password'],
|
||||||
|
original_username: row['user_username'],
|
||||||
|
original_gossamer_id: row['user_id']
|
||||||
|
}
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
# For each user, add user ID mapping to SQLite now that we know what the Discourse user ID is
|
# For each user, add user ID mapping to SQLite now that we know what the Discourse user ID is
|
||||||
users.each do |user|
|
users.each do |user|
|
||||||
@ -626,6 +648,27 @@ class GossamerForumsImporter < ImportScripts::Base
|
|||||||
# Import and set user Bio and Images
|
# Import and set user Bio and Images
|
||||||
def set_user_bio_images
|
def set_user_bio_images
|
||||||
puts "Setting User Bio and Images..."
|
puts "Setting User Bio and Images..."
|
||||||
|
users = []
|
||||||
|
|
||||||
|
# Fetch all users from Gossamer Forums
|
||||||
|
execute_query("SELECT * FROM gforum_User").each do |row|
|
||||||
|
users << {
|
||||||
|
id: row['user_id'],
|
||||||
|
username: sanitize_username(row['user_username'], row['user_email'], row['user_real_name']),
|
||||||
|
email: row['user_email'],
|
||||||
|
created_at: Time.at(row['user_registered']),
|
||||||
|
updated_at: Time.at(row['user_last_seen']),
|
||||||
|
name: row['user_real_name'],
|
||||||
|
title: row['user_title'],
|
||||||
|
bio_raw: row['user_about'] || "",
|
||||||
|
website: row['user_homepage'],
|
||||||
|
location: row['user_location'],
|
||||||
|
md5_password: row['user_password'],
|
||||||
|
original_username: row['user_username'],
|
||||||
|
original_gossamer_id: row['user_id']
|
||||||
|
}
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
# For each user, append user bio and import user files
|
# For each user, append user bio and import user files
|
||||||
users.each do |user|
|
users.each do |user|
|
||||||
|
Loading…
Reference in New Issue
Block a user