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'])
|
||||||
@ -880,21 +881,37 @@ class GossamerForumsImporter < ImportScripts::Base
|
|||||||
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
|
begin
|
||||||
puts "#2"
|
suffix = 1
|
||||||
unique_title = generate_unique_title(title, discourse_user_id, Time.at(row['post_time']))
|
topic_created = false
|
||||||
puts "CREATE TOPIC unique_title #{unique_title} title #{title} discourse_user_id #{discourse_user_id} category_id #{discourse_category_id}"
|
|
||||||
topic = Topic.create!(
|
|
||||||
title: unique_title,
|
|
||||||
user_id: discourse_user_id,
|
|
||||||
created_at: Time.at(row['post_time']),
|
|
||||||
updated_at: Time.at(row['post_time']),
|
|
||||||
category_id: discourse_category_id,
|
|
||||||
views: post_views || 0,
|
|
||||||
posts_count: 0
|
|
||||||
)
|
|
||||||
topic.custom_fields['original_gossamer_id'] = row['post_id']
|
|
||||||
topic.save!
|
|
||||||
|
|
||||||
|
while !topic_created
|
||||||
|
begin
|
||||||
|
puts "#2"
|
||||||
|
unique_title = generate_unique_title(title, discourse_user_id, Time.at(row['post_time']))
|
||||||
|
puts "CREATE TOPIC unique_title #{unique_title} title #{title} discourse_user_id #{discourse_user_id} category_id #{discourse_category_id}"
|
||||||
|
topic = Topic.create!(
|
||||||
|
title: unique_title,
|
||||||
|
user_id: discourse_user_id,
|
||||||
|
created_at: Time.at(row['post_time']),
|
||||||
|
updated_at: Time.at(row['post_time']),
|
||||||
|
category_id: discourse_category_id,
|
||||||
|
views: post_views || 0,
|
||||||
|
posts_count: 0
|
||||||
|
)
|
||||||
|
topic.custom_fields['original_gossamer_id'] = row['post_id']
|
||||||
|
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