Commit 88b7e697 authored by Illya Klymov's avatar Illya Klymov

Address backend maintainer comments

parent 531fc3a1
......@@ -77,10 +77,6 @@ class Import::BaseController < ApplicationController
NamespaceSerializer.new.represent(namespaces)
end
def already_added_project_names
@already_added_projects_names ||= already_added_projects.pluck(:import_source) # rubocop:disable CodeReuse/ActiveRecord
end
def namespaces
current_user.manageable_groups_with_routes
end
......
......@@ -80,7 +80,7 @@ class Import::BitbucketController < Import::BaseController
# rubocop: disable CodeReuse/ActiveRecord
override :importable_repos
def importable_repos
already_added_projects_names = already_added_projects.pluck(:import_source)
already_added_projects_names = already_added_projects.map(&:import_source)
bitbucket_repos.reject { |repo| (already_added_projects_names.include? repo.full_name) || !repo.valid? }
end
......
......@@ -49,8 +49,6 @@ class Import::BitbucketServerController < Import::BaseController
else
render json: { errors: _('This namespace has already been taken! Please choose another one.') }, status: :unprocessable_entity
end
rescue BitbucketServer::Connection::ConnectionError => error
render json: { errors: _("Unable to connect to server: %{error}") % { error: error } }, status: :unprocessable_entity
end
def configure
......@@ -91,7 +89,7 @@ class Import::BitbucketServerController < Import::BaseController
def importable_repos
# Use the import URL to filter beyond what BaseService#find_already_added_projects
already_added_projects = filter_added_projects('bitbucket_server', bitbucket_repos.map(&:browse_url))
already_added_projects_names = already_added_projects.pluck(:import_source)
already_added_projects_names = already_added_projects.map(&:import_source)
bitbucket_repos.reject { |repo| already_added_projects_names.include?(repo.browse_url) || !repo.valid? }
end
......
......@@ -90,7 +90,7 @@ class Import::FogbugzController < Import::BaseController
def importable_repos
repos = client.repos
already_added_projects_names = already_added_projects.pluck(:import_source)
already_added_projects_names = already_added_projects.map(&:import_source)
repos.reject { |repo| already_added_projects_names.include? repo.name }
end
......
......@@ -57,7 +57,7 @@ class Import::GitlabController < Import::BaseController
def importable_repos
repos = client.projects(starting_page: 1, page_limit: MAX_PROJECT_PAGES, per_page: PER_PAGE_PROJECTS)
already_added_projects_names = already_added_projects.pluck(:import_source)
already_added_projects_names = already_added_projects.map(&:import_source)
repos.reject { |repo| already_added_projects_names.include? repo["path_with_namespace"] }
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment