From 7c2406e9e041f3f51aa26eed166724a09baa0690 Mon Sep 17 00:00:00 2001 From: pgcd Date: Tue, 5 Nov 2024 06:06:54 +0100 Subject: [PATCH] Fixes formatting to satisfy stree requirements --- script/import_scripts/smf2.rb | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/script/import_scripts/smf2.rb b/script/import_scripts/smf2.rb index 2e424ee1c8a..8f77340fd0a 100644 --- a/script/import_scripts/smf2.rb +++ b/script/import_scripts/smf2.rb @@ -12,7 +12,7 @@ require "open3" class ImportScripts::Smf2 < ImportScripts::Base BATCH_SIZE ||= 5000 - + def self.run options = Options.new begin @@ -291,12 +291,12 @@ class ImportScripts::Smf2 < ImportScripts::Base .order(:id) .pluck( "string_agg(topic_allowed_users.user_id::text, ',' ORDER BY topic_allowed_users.user_id), title, topics.id", - ) + ) .each do |users, title, topic_id| - @pm_mapping[users] ||= {} - @pm_mapping[users][title] ||= [] - @pm_mapping[users][title] << topic_id - end + @pm_mapping[users] ||= {} + @pm_mapping[users][title] ||= [] + @pm_mapping[users][title] << topic_id + end puts "", "Importing personal posts..." @@ -304,7 +304,8 @@ class ImportScripts::Smf2 < ImportScripts::Base total = query( "SELECT COUNT(*) count FROM smf_personal_messages WHERE deleted_by_sender = 0", - as: :single) + as: :single, + ) batches(BATCH_SIZE) do |offset| posts = query(<<~SQL, as: :array) @@ -339,18 +340,13 @@ class ImportScripts::Smf2 < ImportScripts::Base puts id next if post_id_from_imported_post_id(id) - post = { - id: id, - created_at: Time.at(p[:msgtime]), - user_id: user_id, - } + post = { id: id, created_at: Time.at(p[:msgtime]), user_id: user_id } begin post[:raw] = convert_message_body(p[:body]) rescue StandardError post[:raw] = "-- MESSAGE SKIPPED --" end - users = (recipients + [user_id]).sort.uniq.join(",") title = decode_entities(p[:subject]) @@ -383,7 +379,6 @@ class ImportScripts::Smf2 < ImportScripts::Base @pm_mapping[users][title][-1] end - def import_attachment(post, attachment) path = find_smf_attachment_path(