From 7a6d772ad28ce4e30748e0a4ddcae1c639ced2fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9gis=20Hanol?= Date: Mon, 6 Jul 2020 17:41:28 +0200 Subject: [PATCH] DEV: couple bug fixes in getsatisfaction importer - Ensure we don't modify a frozen string - Ensure we have a slug before trying to create a permalink --- script/import_scripts/getsatisfaction.rb | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/script/import_scripts/getsatisfaction.rb b/script/import_scripts/getsatisfaction.rb index fa8d51c81d0..495cc50c0ed 100644 --- a/script/import_scripts/getsatisfaction.rb +++ b/script/import_scripts/getsatisfaction.rb @@ -351,7 +351,7 @@ class ImportScripts::GetSatisfaction < ImportScripts::Base raw.gsub!(" ", "\n\n") hoisted.each do |hoist, code| - raw.gsub!(hoist, "\n```\n" << code << "\n```\n") + raw.gsub!(hoist, "\n```\n#{code}\n```\n") end raw = CGI.unescapeHTML(raw) @@ -365,9 +365,10 @@ class ImportScripts::GetSatisfaction < ImportScripts::Base Topic.listable_topics.find_each do |topic| tcf = topic.first_post.custom_fields if tcf && tcf["import_id"] - slug = @topic_slug[tcf["import_id"]] - slug = slug.gsub(OLD_DOMAIN, "") - Permalink.create(url: slug, topic_id: topic.id) + if slug = @topic_slug[tcf["import_id"]] + slug.gsub!(OLD_DOMAIN, "") + Permalink.find_or_create_by(url: slug, topic_id: topic.id) if slug.present? + end end end end