FIX: don't use latest activity as user's bio in vanilla import by default
This commit is contained in:
parent
10db8f21d7
commit
898ceb41e8
|
@ -8,6 +8,8 @@ class ImportScripts::Vanilla < ImportScripts::Base
|
|||
|
||||
@vanilla_file = ARGV[0]
|
||||
raise ArgumentError.new('Vanilla file argument missing. Provide full path to vanilla csv file.') if @vanilla_file.blank?
|
||||
|
||||
@use_lastest_activity_as_user_bio = true if ARGV.include?('use-latest-activity-as-user-bio')
|
||||
end
|
||||
|
||||
def execute
|
||||
|
@ -53,7 +55,9 @@ class ImportScripts::Vanilla < ImportScripts::Base
|
|||
data << line.strip
|
||||
end
|
||||
# PERF: don't parse useless tables
|
||||
next if ["user_meta"].include? table
|
||||
useless_tables = ["user_meta"]
|
||||
useless_tables << "activities" unless @use_lastest_activity_as_user_bio
|
||||
next if useless_tables.include?(table)
|
||||
# parse the data
|
||||
puts "parsing #{table}..."
|
||||
parsed_data = CSV.parse(data.join("\n"), headers: true, header_converters: :symbol).map { |row| row.to_hash }
|
||||
|
@ -83,8 +87,12 @@ class ImportScripts::Vanilla < ImportScripts::Base
|
|||
create_users(@users) do |user|
|
||||
next if user[:name] == "[Deleted User]"
|
||||
|
||||
last_activity = activities.select { |a| user[:user_id] == a[:activity_user_id] }.last
|
||||
bio_raw = last_activity.try(:[], :story) || ""
|
||||
if @use_lastest_activity_as_user_bio
|
||||
last_activity = activities.select { |a| user[:user_id] == a[:activity_user_id] }.last
|
||||
bio_raw = last_activity.try(:[], :story) || ""
|
||||
else
|
||||
bio_raw = user[:discovery_text]
|
||||
end
|
||||
|
||||
u = {
|
||||
id: user[:user_id],
|
||||
|
@ -97,10 +105,6 @@ class ImportScripts::Vanilla < ImportScripts::Base
|
|||
admin: @user_roles.select { |ur| ur[:user_id] == user[:user_id] }.map { |ur| ur[:role_id] }.include?(admin_role_id),
|
||||
}
|
||||
|
||||
# if @comments.select { |c| c[:insert_user_id] == user[:user_id] }.map { |c| c[:discussion_id] }.uniq.count > 3
|
||||
# u[:trust_level] = TrustLevel[2]
|
||||
# end
|
||||
|
||||
u
|
||||
end
|
||||
end
|
||||
|
@ -244,9 +248,6 @@ class ImportScripts::Vanilla < ImportScripts::Base
|
|||
.gsub(/<\/?code\s*>/i, "`")
|
||||
.gsub("<", "<")
|
||||
.gsub(">", ">")
|
||||
# .gsub(/`([^`]+)`/im) { "`" + $1.gsub("*", "\u2603") + "`" }
|
||||
# .gsub("*", "\\*")
|
||||
# .gsub("\u2603", "*")
|
||||
end
|
||||
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue