Commit 567263c9 authored by Jarka Košanová's avatar Jarka Košanová

Merge branch 'georgekoltsov/add-group-migration-import-status' into 'master'

Add Group Migration realtime_changes endpoint

See merge request gitlab-org/gitlab!50762
parents f9d2a506 5c8e6634
...@@ -8,6 +8,8 @@ class Import::BulkImportsController < ApplicationController ...@@ -8,6 +8,8 @@ class Import::BulkImportsController < ApplicationController
feature_category :importers feature_category :importers
POLLING_INTERVAL = 3_000
rescue_from BulkImports::Clients::Http::ConnectionError, with: :bulk_import_connection_error rescue_from BulkImports::Clients::Http::ConnectionError, with: :bulk_import_connection_error
def configure def configure
...@@ -34,6 +36,12 @@ class Import::BulkImportsController < ApplicationController ...@@ -34,6 +36,12 @@ class Import::BulkImportsController < ApplicationController
render json: :ok render json: :ok
end end
def realtime_changes
Gitlab::PollingInterval.set_header(response, interval: POLLING_INTERVAL)
render json: current_user_bulk_imports.to_json(only: [:id], methods: [:status_name])
end
private private
def serialized_importable_data def serialized_importable_data
...@@ -152,4 +160,8 @@ class Import::BulkImportsController < ApplicationController ...@@ -152,4 +160,8 @@ class Import::BulkImportsController < ApplicationController
def sanitized_filter_param def sanitized_filter_param
@filter ||= sanitize(params[:filter])&.downcase @filter ||= sanitize(params[:filter])&.downcase
end end
def current_user_bulk_imports
current_user.bulk_imports.gitlab
end
end end
...@@ -63,6 +63,7 @@ namespace :import do ...@@ -63,6 +63,7 @@ namespace :import do
resource :bulk_imports, only: [:create] do resource :bulk_imports, only: [:create] do
post :configure post :configure
get :status get :status
get :realtime_changes
end end
resource :manifest, only: [:create, :new], controller: :manifest do resource :manifest, only: [:create, :new], controller: :manifest do
......
...@@ -149,6 +149,22 @@ RSpec.describe Import::BulkImportsController do ...@@ -149,6 +149,22 @@ RSpec.describe Import::BulkImportsController do
end end
end end
describe 'GET realtime_changes' do
let_it_be(:bulk_import) { create(:bulk_import, :created, user: user) }
it 'returns bulk imports created by current user' do
get :realtime_changes
expect(json_response).to eq([{ 'id' => bulk_import.id, 'status_name' => bulk_import.status_name.to_s }])
end
it 'sets a Poll-Interval header' do
get :realtime_changes
expect(response.headers['Poll-Interval']).to eq(Import::BulkImportsController::POLLING_INTERVAL.to_s)
end
end
describe 'POST create' do describe 'POST create' do
let(:instance_url) { "http://fake-intance" } let(:instance_url) { "http://fake-intance" }
let(:pat) { "fake-pat" } let(:pat) { "fake-pat" }
......
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