A platform for community discussion. Free, open, simple.
DEV: Apply code format to import script (#25063)
Gerhard Schlagerd7601388e5ac
diff --git a/script/import_scripts/fusionforge.rb b/script/import_scripts/fusionforge.rbindex 18ff948e931..8fc368ed9f8 100644--- a/script/import_scripts/fusionforge.rb+++ b/script/import_scripts/fusionforge.rb@@ -1,5 +1,4 @@# frozen_string_literal: true-# (c) 2023 Intevation GmbHrequire "pg"@@ -33,7 +32,9 @@ class ImportScripts::FusionForge < ImportScripts::Basedef import_usersputs "", "creating users"- total_count = @client.exec("+ total_count =+ @client.exec(+ "WITH relevant_posts AS (SELECT DISTINCT posted_by FROM forum)@@ -41,7 +42,10 @@ class ImportScripts::FusionForge < ImportScripts::BaseCOUNT(DISTINCT user_id) AS countFROM users uJOIN relevant_posts f on u.user_id = f.posted_by- ").first["count"]+ ",+ ).first[+ "count"+ ]batches(BATCH_SIZE) do |offset|results =@@ -56,7 +60,7 @@ class ImportScripts::FusionForge < ImportScripts::BaseJOIN relevant_posts f on u.user_id = f.posted_byLIMIT #{BATCH_SIZE}OFFSET #{offset};",- )+ )break if results.ntuples < 1@@ -69,13 +73,13 @@ class ImportScripts::FusionForge < ImportScripts::Baseemail: user["email"],username: user["user_name"],name: user["name"],- active: user["status"] == 'A' && user["unix_pw"] != 'deleted',+ active: user["status"] == "A" && user["unix_pw"] != "deleted",created_at: Time.zone.at(user["add_date"].to_i),- last_emailed_at: nil, # default is "now", which is not true+ last_emailed_at: nil, # default is "now", which is not trueapproved: true,# for https://github.com/communiteq/discourse-migratepassword/# this field results in custom_fields['import_pass']. This also activates the accounts, see base.rb on `u.activate`.- password: user["unix_pw"] != 'deleted' ? user["unix_pw"] : nil,+ password: user["unix_pw"] != "deleted" ? user["unix_pw"] : nil,}endend@@ -94,7 +98,9 @@ class ImportScripts::FusionForge < ImportScripts::Base",).to_a- create_categories(categories) { |category| { id: category["group_id"], name: category["group_name"] } }+ create_categories(categories) do |category|+ { id: category["group_id"], name: category["group_name"] }+ endputs "", "importing forums..."@@ -174,11 +180,14 @@ class ImportScripts::FusionForge < ImportScripts::Basedef import_attachmentsputs "", "importing attachments..."- uploads = @client.exec("+ uploads =+ @client.exec(+ "SELECT msg_id, filename, attachmentidFROM forum_attachmentorder by msg_id- ").to_a+ ",+ ).to_acurrent_count = 0total_count = uploads.count@@ -198,13 +207,9 @@ class ImportScripts::FusionForge < ImportScripts::Basefile_hex = sprintf("%x", upload["attachmentid"])prefix = file_hex[-2..-1]- if not prefix- prefix = file_hex- end+ prefix = file_hex if not prefixpostfix = file_hex[0..-3].to_s- if postfix == ''- postfix = '0'- end+ postfix = "0" if postfix == ""filename = File.join("/tmp/var/lib/fusionforge/forum/", prefix, "/", postfix)upl_obj = create_upload(post.user.id, filename, real_filename)@@ -231,7 +236,6 @@ class ImportScripts::FusionForge < ImportScripts::Baseprint_status(current_count, total_count)endend-endImportScripts::FusionForge.new.perform