v0.25.6 Creative bug workaround??
This commit is contained in:
parent
2087ab7b41
commit
fbc0545f8a
@ -1,5 +1,5 @@
|
|||||||
# gossamer threads migration-import code
|
# gossamer threads migration-import code
|
||||||
# v0.25.5
|
# v0.25.6
|
||||||
|
|
||||||
require 'mysql2'
|
require 'mysql2'
|
||||||
require 'open-uri'
|
require 'open-uri'
|
||||||
@ -872,6 +872,7 @@ class GossamerForumsImporter < ImportScripts::Base
|
|||||||
puts "#1"
|
puts "#1"
|
||||||
# Ensure the title is valid
|
# Ensure the title is valid
|
||||||
title = ensure_valid_title(row['post_subject'])
|
title = ensure_valid_title(row['post_subject'])
|
||||||
|
unique_title = title
|
||||||
|
|
||||||
# Confirm the number of views the post has had
|
# Confirm the number of views the post has had
|
||||||
post_views = fetch_post_views(row['post_id'])
|
post_views = fetch_post_views(row['post_id'])
|
||||||
@ -879,6 +880,11 @@ class GossamerForumsImporter < ImportScripts::Base
|
|||||||
# Skip if the topic already exists
|
# Skip if the topic already exists
|
||||||
unless TopicCustomField.exists?(name: 'original_gossamer_id', value: row['post_id'])
|
unless TopicCustomField.exists?(name: 'original_gossamer_id', value: row['post_id'])
|
||||||
# Create the topic
|
# Create the topic
|
||||||
|
begin
|
||||||
|
suffix = 1
|
||||||
|
topic_created = false
|
||||||
|
|
||||||
|
while !topic_created
|
||||||
begin
|
begin
|
||||||
puts "#2"
|
puts "#2"
|
||||||
unique_title = generate_unique_title(title, discourse_user_id, Time.at(row['post_time']))
|
unique_title = generate_unique_title(title, discourse_user_id, Time.at(row['post_time']))
|
||||||
@ -895,6 +901,17 @@ class GossamerForumsImporter < ImportScripts::Base
|
|||||||
topic.custom_fields['original_gossamer_id'] = row['post_id']
|
topic.custom_fields['original_gossamer_id'] = row['post_id']
|
||||||
topic.save!
|
topic.save!
|
||||||
|
|
||||||
|
topic_created = true
|
||||||
|
|
||||||
|
rescue ActiveRecord::RecordInvalid => e
|
||||||
|
if e.message.include?("Title has already been used")
|
||||||
|
unique_title = "#{base_title} (#{suffix})"
|
||||||
|
suffix += 1
|
||||||
|
else
|
||||||
|
raise e
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
# Track last post time and user for the topic
|
# Track last post time and user for the topic
|
||||||
# topic_last_post_time[topic.id] = Time.at(row['post_time'])
|
# topic_last_post_time[topic.id] = Time.at(row['post_time'])
|
||||||
# topic_last_post_user[topic.id] = discourse_user_id
|
# topic_last_post_user[topic.id] = discourse_user_id
|
||||||
|
Loading…
Reference in New Issue
Block a user