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
1a0c2329
Commit
1a0c2329
authored
Dec 10, 2021
by
Kassio Borges
Committed by
Kerri Miller
Dec 10, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
GithubImporter: Expose import stats on import status endpoint
parent
6bd1a6f6
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
76 additions
and
1 deletion
+76
-1
doc/api/project_import_export.md
doc/api/project_import_export.md
+52
-1
lib/api/entities/project_import_status.rb
lib/api/entities/project_import_status.rb
+6
-0
spec/lib/api/entities/project_import_status_spec.rb
spec/lib/api/entities/project_import_status_spec.rb
+18
-0
No files found.
doc/api/project_import_export.md
View file @
1a0c2329
...
...
@@ -294,6 +294,7 @@ The `failed_relations` array is capped to 100 items.
"path_with_namespace"
:
"gitlab-org/gitlab-test"
,
"created_at"
:
"2017-08-29T04:36:44.383Z"
,
"import_status"
:
"started"
,
"import_type"
:
"github"
,
"correlation_id"
:
"mezklWso3Za"
,
"failed_relations"
:
[
{
...
...
@@ -302,8 +303,58 @@ The `failed_relations` array is capped to 100 items.
"exception_class"
:
"RuntimeError"
,
"exception_message"
:
"A failure occurred"
,
"source"
:
"custom error context"
,
"relation_name"
:
"merge_requests"
"relation_name"
:
"merge_requests"
,
"line_number"
:
0
}
]
}
```
When importing from GitHub, the a
`stats`
field lists how many objects were already fetched from
GitHub and how many were already imported:
```
json
{
"id"
:
1
,
"description"
:
"Itaque perspiciatis minima aspernatur corporis consequatur."
,
"name"
:
"Gitlab Test"
,
"name_with_namespace"
:
"Gitlab Org / Gitlab Test"
,
"path"
:
"gitlab-test"
,
"path_with_namespace"
:
"gitlab-org/gitlab-test"
,
"created_at"
:
"2017-08-29T04:36:44.383Z"
,
"import_status"
:
"started"
,
"import_type"
:
"github"
,
"correlation_id"
:
"mezklWso3Za"
,
"failed_relations"
:
[
{
"id"
:
42
,
"created_at"
:
"2020-04-02T14:48:59.526Z"
,
"exception_class"
:
"RuntimeError"
,
"exception_message"
:
"A failure occurred"
,
"source"
:
"custom error context"
,
"relation_name"
:
"merge_requests"
,
"line_number"
:
0
}
],
"stats"
:
{
"fetched"
:
{
"diff_note"
:
19
,
"issue"
:
3
,
"label"
:
1
,
"note"
:
3
,
"pull_request"
:
2
,
"pull_request_merged_by"
:
1
,
"pull_request_review"
:
16
},
"imported"
:
{
"diff_note"
:
19
,
"issue"
:
3
,
"label"
:
1
,
"note"
:
3
,
"pull_request"
:
2
,
"pull_request_merged_by"
:
1
,
"pull_request_review"
:
16
}
}
}
```
lib/api/entities/project_import_status.rb
View file @
1a0c2329
...
...
@@ -16,6 +16,12 @@ module API
expose
:import_error
do
|
project
,
_options
|
project
.
import_state
&
.
last_error
end
expose
:stats
do
|
project
,
_options
|
if
project
.
github_import?
::
Gitlab
::
GithubImport
::
ObjectCounter
.
summary
(
project
)
end
end
end
end
end
spec/lib/api/entities/project_import_status_spec.rb
View file @
1a0c2329
...
...
@@ -17,6 +17,7 @@ RSpec.describe API::Entities::ProjectImportStatus, :aggregate_failures do
expect
(
subject
[
:correlation_id
]).
to
be_nil
expect
(
subject
[
:import_error
]).
to
be_nil
expect
(
subject
[
:failed_relations
]).
to
eq
([])
expect
(
subject
[
:stats
]).
to
be_nil
end
end
...
...
@@ -76,5 +77,22 @@ RSpec.describe API::Entities::ProjectImportStatus, :aggregate_failures do
expect
(
subject
[
:failed_relations
]).
to
eq
([])
end
end
context
'when importing from github'
,
:clean_gitlab_redis_cache
do
let
(
:project
)
{
create
(
:project
,
:import_failed
,
import_type:
'github'
)
}
let
(
:entity
)
{
described_class
.
new
(
project
)
}
before
do
::
Gitlab
::
GithubImport
::
ObjectCounter
.
increment
(
project
,
:issues
,
:fetched
,
value:
10
)
::
Gitlab
::
GithubImport
::
ObjectCounter
.
increment
(
project
,
:issues
,
:imported
,
value:
8
)
end
it
'exposes the import stats'
do
expect
(
subject
[
:stats
]).
to
eq
(
'fetched'
=>
{
'issues'
=>
10
},
'imported'
=>
{
'issues'
=>
8
}
)
end
end
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