mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 03:51:07 +08:00
DEV: Apply syntax_tree formatting to script/*
This commit is contained in:
@ -1,6 +1,6 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'mysql2'
|
||||
require "mysql2"
|
||||
|
||||
module ImportScripts::PhpBB3
|
||||
class Database
|
||||
@ -19,11 +19,11 @@ module ImportScripts::PhpBB3
|
||||
def create_database
|
||||
version = get_phpbb_version
|
||||
|
||||
if version.start_with?('3.0')
|
||||
require_relative 'database_3_0'
|
||||
if version.start_with?("3.0")
|
||||
require_relative "database_3_0"
|
||||
Database_3_0.new(@database_client, @database_settings)
|
||||
elsif version.start_with?('3.1') || version.start_with?('3.2') || version.start_with?('3.3')
|
||||
require_relative 'database_3_1'
|
||||
elsif version.start_with?("3.1") || version.start_with?("3.2") || version.start_with?("3.3")
|
||||
require_relative "database_3_1"
|
||||
Database_3_1.new(@database_client, @database_settings)
|
||||
else
|
||||
raise UnsupportedVersionError, <<~TEXT
|
||||
@ -42,7 +42,7 @@ module ImportScripts::PhpBB3
|
||||
username: @database_settings.username,
|
||||
password: @database_settings.password,
|
||||
database: @database_settings.schema,
|
||||
reconnect: true
|
||||
reconnect: true,
|
||||
)
|
||||
end
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require_relative 'database_base'
|
||||
require_relative '../support/constants'
|
||||
require_relative "database_base"
|
||||
require_relative "../support/constants"
|
||||
|
||||
module ImportScripts::PhpBB3
|
||||
class Database_3_0 < DatabaseBase
|
||||
|
@ -1,7 +1,7 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require_relative 'database_3_0'
|
||||
require_relative '../support/constants'
|
||||
require_relative "database_3_0"
|
||||
require_relative "../support/constants"
|
||||
|
||||
module ImportScripts::PhpBB3
|
||||
class Database_3_1 < Database_3_0
|
||||
@ -32,14 +32,15 @@ module ImportScripts::PhpBB3
|
||||
private
|
||||
|
||||
def profile_fields_query(profile_fields)
|
||||
@profile_fields_query ||= begin
|
||||
if profile_fields.present?
|
||||
columns = profile_fields.map { |field| "pf_#{field[:phpbb_field_name]}" }
|
||||
", #{columns.join(', ')}"
|
||||
else
|
||||
""
|
||||
@profile_fields_query ||=
|
||||
begin
|
||||
if profile_fields.present?
|
||||
columns = profile_fields.map { |field| "pf_#{field[:phpbb_field_name]}" }
|
||||
", #{columns.join(", ")}"
|
||||
else
|
||||
""
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -39,9 +39,7 @@ module ImportScripts::PhpBB3
|
||||
def find_last_row(rows)
|
||||
last_index = rows.size - 1
|
||||
|
||||
rows.each_with_index do |row, index|
|
||||
return row if index == last_index
|
||||
end
|
||||
rows.each_with_index { |row, index| return row if index == last_index }
|
||||
|
||||
nil
|
||||
end
|
||||
|
Reference in New Issue
Block a user