Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
0fb3f04c
Commit
0fb3f04c
authored
Mar 23, 2022
by
Illya Klymov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Expose github stats in realtime_changes private API
* Add ability to view realtime stats for github Changelog: added
parent
98da9924
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
2 deletions
+26
-2
app/controllers/import/github_controller.rb
app/controllers/import/github_controller.rb
+9
-1
spec/controllers/import/github_controller_spec.rb
spec/controllers/import/github_controller_spec.rb
+16
-0
spec/support/shared_examples/controllers/githubish_import_controller_shared_examples.rb
...ontrollers/githubish_import_controller_shared_examples.rb
+1
-1
No files found.
app/controllers/import/github_controller.rb
View file @
0fb3f04c
...
...
@@ -62,7 +62,15 @@ class Import::GithubController < Import::BaseController
end
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
protected
...
...
spec/controllers/import/github_controller_spec.rb
View file @
0fb3f04c
...
...
@@ -293,6 +293,22 @@ RSpec.describe Import::GithubController do
end
describe
"GET realtime_changes"
do
let
(
:user
)
{
create
(
:user
)
}
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
spec/support/shared_examples/controllers/githubish_import_controller_shared_examples.rb
View file @
0fb3f04c
...
...
@@ -515,7 +515,7 @@ RSpec.shared_examples 'a GitHub-ish import controller: GET realtime_changes' do
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
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment