Commit 4df7f344 authored by Stan Hu's avatar Stan Hu

Merge branch 'xanf-expose-github-stats-in-realtime-changes' into 'master'

Expose github stats in realtime_changes private API

See merge request gitlab-org/gitlab!83497
parents b453095d 0fb3f04c
...@@ -62,7 +62,15 @@ class Import::GithubController < Import::BaseController ...@@ -62,7 +62,15 @@ class Import::GithubController < Import::BaseController
end end
def realtime_changes def realtime_changes
super 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)
}
}
end end
protected protected
......
...@@ -293,6 +293,22 @@ RSpec.describe Import::GithubController do ...@@ -293,6 +293,22 @@ RSpec.describe Import::GithubController do
end end
describe "GET realtime_changes" do describe "GET realtime_changes" do
let(:user) { create(:user) }
it_behaves_like 'a GitHub-ish import controller: GET realtime_changes' it_behaves_like 'a GitHub-ish import controller: GET realtime_changes'
before do
assign_session_token(provider)
end
it 'includes stats in response' do
create(:project, import_type: provider, namespace: user.namespace, import_status: :finished, import_source: 'example/repo')
get :realtime_changes
expect(json_response[0]).to include('stats')
expect(json_response[0]['stats']).to include('fetched')
expect(json_response[0]['stats']).to include('imported')
end
end end
end end
...@@ -515,7 +515,7 @@ RSpec.shared_examples 'a GitHub-ish import controller: GET realtime_changes' do ...@@ -515,7 +515,7 @@ RSpec.shared_examples 'a GitHub-ish import controller: GET realtime_changes' do
get :realtime_changes get :realtime_changes
expect(json_response).to eq([{ "id" => project.id, "import_status" => project.import_status }]) expect(json_response).to match([a_hash_including({ "id" => project.id, "import_status" => project.import_status })])
expect(Integer(response.headers['Poll-Interval'])).to be > -1 expect(Integer(response.headers['Poll-Interval'])).to be > -1
end end
end 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