From 9d6e1a0b7cfcad1ab374f38bf3d28be83c403c67 Mon Sep 17 00:00:00 2001 From: saint Date: Mon, 19 Aug 2024 13:26:37 +1000 Subject: [PATCH] v0.48.6 48-48-48, add handling for deleted-former user as OP poster --- gossamer_forums.rb | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/gossamer_forums.rb b/gossamer_forums.rb index d679e1a..33c65b1 100644 --- a/gossamer_forums.rb +++ b/gossamer_forums.rb @@ -1,7 +1,7 @@ # Federated Computer, Inc. # David Sainty 2024 A.D. # Gossamer Threads to Discourse -- Migration-Import Script -# v0.48.5 Batch size 1000, double councurrency numbers +# v0.48.6 48-48-48, add handling for deleted-former user as OP poster require 'mysql2' require 'open-uri' @@ -1324,7 +1324,18 @@ class GossamerForumsImporter < ImportScripts::Base # Fetch the mapped Discourse user and category ID based on Gossamer data discourse_user_id = fetch_user_id_mapping(row['user_id_fk']) + + # Check to be certain user has not been deleted, etc. + if discourse_user_id.nil? || discourse_user_id == 0 + puts "discourse_user_id is NIL/ZERO for post_id #{row['post_id']}" + discourse_former_user = User.find_by(username: 'Former_User') + discourse_user_id = discourse_former_user.id + puts "discourse_user_id is NOW Former_User id #{discourse_user_id} for post_id #{row['post_id']}" + end + + # Fetch the mapped Discourse user and category ID based on Gossamer data discourse_category_id = fetch_category_id_mapping(row['forum_id_fk']) + puts "discourse_user_id #{discourse_user_id} discourse_category_id #{discourse_category_id}" return unless discourse_user_id && discourse_category_id