Add rubocop to our build. (#5004)
This commit is contained in:
@@ -47,15 +47,15 @@ module ImportScripts::PhpBB3
|
||||
|
||||
def get_avatar_path(avatar_type, filename)
|
||||
case avatar_type
|
||||
when Constants::AVATAR_TYPE_UPLOADED then
|
||||
filename.gsub!(/_[0-9]+\./, '.') # we need 1337.jpg, not 1337_2983745.jpg
|
||||
when Constants::AVATAR_TYPE_UPLOADED then
|
||||
filename.gsub!(/_[0-9]+\./, '.') # we need 1337.jpg, not 1337_2983745.jpg
|
||||
get_uploaded_path(filename)
|
||||
when Constants::AVATAR_TYPE_GALLERY then
|
||||
get_gallery_path(filename)
|
||||
when Constants::AVATAR_TYPE_REMOTE then
|
||||
download_avatar(filename)
|
||||
when Constants::AVATAR_TYPE_GALLERY then
|
||||
get_gallery_path(filename)
|
||||
when Constants::AVATAR_TYPE_REMOTE then
|
||||
download_avatar(filename)
|
||||
else
|
||||
Rails.logger.error("Invalid avatar type #{avatar_type}. Skipping...")
|
||||
Rails.logger.error("Invalid avatar type #{avatar_type}. Skipping...")
|
||||
nil
|
||||
end
|
||||
end
|
||||
@@ -97,14 +97,14 @@ module ImportScripts::PhpBB3
|
||||
|
||||
def is_allowed_avatar_type?(avatar_type)
|
||||
case avatar_type
|
||||
when Constants::AVATAR_TYPE_UPLOADED then
|
||||
@settings.import_uploaded_avatars
|
||||
when Constants::AVATAR_TYPE_REMOTE then
|
||||
@settings.import_remote_avatars
|
||||
when Constants::AVATAR_TYPE_GALLERY then
|
||||
@settings.import_gallery_avatars
|
||||
when Constants::AVATAR_TYPE_UPLOADED then
|
||||
@settings.import_uploaded_avatars
|
||||
when Constants::AVATAR_TYPE_REMOTE then
|
||||
@settings.import_remote_avatars
|
||||
when Constants::AVATAR_TYPE_GALLERY then
|
||||
@settings.import_gallery_avatars
|
||||
else
|
||||
false
|
||||
false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -41,8 +41,8 @@ module ImportScripts::PhpBB3
|
||||
end
|
||||
|
||||
if row[:forum_desc].present?
|
||||
changes = {raw: @text_processor.process_raw_text(row[:forum_desc])}
|
||||
opts = {revised_at: post.created_at, bypass_bump: true}
|
||||
changes = { raw: @text_processor.process_raw_text(row[:forum_desc]) }
|
||||
opts = { revised_at: post.created_at, bypass_bump: true }
|
||||
post.revise(Discourse.system_user, changes, opts)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -17,7 +17,6 @@ module ImportScripts::PhpBB3
|
||||
rows.map { |row| get_import_id(row[:msg_id]) }
|
||||
end
|
||||
|
||||
|
||||
def map_message(row)
|
||||
user_id = @lookup.user_id_from_imported_user_id(row[:author_id]) || Discourse.system_user.id
|
||||
attachments = import_attachments(row, user_id)
|
||||
@@ -54,7 +53,7 @@ module ImportScripts::PhpBB3
|
||||
mapped[:title] = get_topic_title(row)
|
||||
mapped[:archetype] = Archetype.private_message
|
||||
mapped[:target_usernames] = get_recipient_usernames(row)
|
||||
mapped[:custom_fields] = {import_user_ids: current_user_ids.join(',')}
|
||||
mapped[:custom_fields] = { import_user_ids: current_user_ids.join(',') }
|
||||
|
||||
if mapped[:target_usernames].empty?
|
||||
puts "Private message without recipients. Skipping #{row[:msg_id]}: #{row[:message_subject][0..40]}"
|
||||
@@ -127,7 +126,7 @@ module ImportScripts::PhpBB3
|
||||
.joins(:topic)
|
||||
.joins(:_custom_fields)
|
||||
.where(["LOWER(topics.title) IN (:titles) AND post_custom_fields.name = 'import_user_ids' AND post_custom_fields.value = :user_ids",
|
||||
{titles: topic_titles, user_ids: current_user_ids.join(',')}])
|
||||
{ titles: topic_titles, user_ids: current_user_ids.join(',') }])
|
||||
.order('topics.created_at DESC')
|
||||
.first.try(:topic_id)
|
||||
end
|
||||
|
||||
@@ -35,7 +35,7 @@ module ImportScripts::PhpBB3
|
||||
|
||||
def get_poll_options(topic_id)
|
||||
rows = @database.fetch_poll_options(topic_id)
|
||||
options_by_text = Hash.new { |h, k| h[k] = {ids: [], total_votes: 0, anonymous_votes: 0} }
|
||||
options_by_text = Hash.new { |h, k| h[k] = { ids: [], total_votes: 0, anonymous_votes: 0 } }
|
||||
|
||||
rows.each do |row|
|
||||
option_text = @text_processor.process_raw_text(row[:poll_option_text]).delete("\n")
|
||||
@@ -100,7 +100,7 @@ module ImportScripts::PhpBB3
|
||||
|
||||
# @param custom_fields [Hash]
|
||||
def add_poll_to_custom_fields(custom_fields, extracted_poll)
|
||||
custom_fields[DiscoursePoll::POLLS_CUSTOM_FIELD] = {DiscoursePoll::DEFAULT_POLL_NAME => extracted_poll}
|
||||
custom_fields[DiscoursePoll::POLLS_CUSTOM_FIELD] = { DiscoursePoll::DEFAULT_POLL_NAME => extracted_poll }
|
||||
end
|
||||
|
||||
# @param custom_fields [Hash]
|
||||
|
||||
@@ -44,7 +44,7 @@ module ImportScripts::PhpBB3
|
||||
@import_remote_avatars = avatar_settings['remote']
|
||||
@import_gallery_avatars = avatar_settings['gallery']
|
||||
|
||||
@use_bbcode_to_md =import_settings['use_bbcode_to_md']
|
||||
@use_bbcode_to_md = import_settings['use_bbcode_to_md']
|
||||
|
||||
@original_site_prefix = import_settings['site_prefix']['original']
|
||||
@new_site_prefix = import_settings['site_prefix']['new']
|
||||
|
||||
Reference in New Issue
Block a user