Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2023-02-20 16:49:51 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2023-02-20 16:49:51 +0300
commit71786ddc8e28fbd3cb3fcc4b3ff15e5962a1c82e (patch)
tree6a2d93ef3fb2d353bb7739e4b57e6541f51cdd71 /app/controllers/import
parenta7253423e3403b8c08f8a161e5937e1488f5f407 (diff)
Add latest changes from gitlab-org/gitlab@15-9-stable-eev15.9.0-rc42
Diffstat (limited to 'app/controllers/import')
-rw-r--r--app/controllers/import/bulk_imports_controller.rb5
-rw-r--r--app/controllers/import/github_controller.rb25
2 files changed, 23 insertions, 7 deletions
diff --git a/app/controllers/import/bulk_imports_controller.rb b/app/controllers/import/bulk_imports_controller.rb
index e9705c45116..f4eea3abd32 100644
--- a/app/controllers/import/bulk_imports_controller.rb
+++ b/app/controllers/import/bulk_imports_controller.rb
@@ -53,6 +53,7 @@ class Import::BulkImportsController < ApplicationController
end
def create
+ return render json: { success: false }, status: :too_many_requests if throttled_request?
return render json: { success: false }, status: :unprocessable_entity unless valid_create_params?
responses = create_params.map do |entry|
@@ -204,4 +205,8 @@ class Import::BulkImportsController < ApplicationController
def current_user_bulk_imports
current_user.bulk_imports.gitlab
end
+
+ def throttled_request?
+ ::Gitlab::ApplicationRateLimiter.throttled_request?(request, current_user, :bulk_import, scope: current_user)
+ end
end
diff --git a/app/controllers/import/github_controller.rb b/app/controllers/import/github_controller.rb
index 9a8f6a74653..0bee1faccf5 100644
--- a/app/controllers/import/github_controller.rb
+++ b/app/controllers/import/github_controller.rb
@@ -79,13 +79,7 @@ class Import::GithubController < Import::BaseController
def realtime_changes
Gitlab::PollingInterval.set_header(response, interval: 3_000)
- render json: already_added_projects.map { |project|
- {
- id: project.id,
- import_status: project.import_status,
- stats: ::Gitlab::GithubImport::ObjectCounter.summary(project)
- }
- }
+ render json: Import::GithubRealtimeRepoSerializer.new.represent(already_added_projects)
end
def cancel
@@ -99,6 +93,23 @@ class Import::GithubController < Import::BaseController
end
end
+ def cancel_all
+ projects_to_cancel = Project.imported_from(provider_name).created_by(current_user).is_importing
+
+ canceled = projects_to_cancel.map do |project|
+ # #reset is called to make sure project was not finished/canceled brefore calling service
+ result = Import::Github::CancelProjectImportService.new(project.reset, current_user).execute
+
+ {
+ id: project.id,
+ status: result[:status],
+ error: result[:message]
+ }.compact
+ end
+
+ render json: canceled
+ end
+
protected
override :importable_repos