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
0
Merge Requests
0
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
Boxiang Sun
gitlab-ce
Commits
749c3893
Commit
749c3893
authored
Aug 28, 2017
by
Travis Miller
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add time stats to issue and merge request API end points
parent
ce1ce820
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
39 additions
and
13 deletions
+39
-13
lib/api/entities.rb
lib/api/entities.rb
+21
-1
lib/api/issues.rb
lib/api/issues.rb
+17
-11
lib/api/merge_requests.rb
lib/api/merge_requests.rb
+1
-1
No files found.
lib/api/entities.rb
View file @
749c3893
...
...
@@ -354,6 +354,10 @@ module API
expose
:web_url
do
|
issue
,
options
|
Gitlab
::
UrlBuilder
.
build
(
issue
)
end
expose
:time_stats
,
using:
'API::Entities::IssuableTimeStats'
do
|
issue
|
issue
end
end
class
Issue
<
IssueBasic
...
...
@@ -383,10 +387,22 @@ module API
end
class
IssuableTimeStats
<
Grape
::
Entity
format_with
(
:time_tracking_formatter
)
do
|
time_spent
|
Gitlab
::
TimeTrackingFormatter
.
output
(
time_spent
)
end
expose
:time_estimate
expose
:total_time_spent
expose
:human_time_estimate
expose
:human_total_time_spent
with_options
(
format_with: :time_tracking_formatter
)
do
expose
:total_time_spent
,
as: :human_total_time_spent
end
def
total_time_spent
# Avoids an N+1 query since timelogs are preloaded
object
.
timelogs
.
map
(
&
:time_spent
).
sum
end
end
class
ExternalIssue
<
Grape
::
Entity
...
...
@@ -436,6 +452,10 @@ module API
expose
:web_url
do
|
merge_request
,
options
|
Gitlab
::
UrlBuilder
.
build
(
merge_request
)
end
expose
:time_stats
,
using:
'API::Entities::IssuableTimeStats'
do
|
merge_request
|
merge_request
end
end
class
MergeRequest
<
MergeRequestBasic
...
...
lib/api/issues.rb
View file @
749c3893
...
...
@@ -15,7 +15,7 @@ module API
args
[
:label_name
]
=
args
.
delete
(
:labels
)
issues
=
IssuesFinder
.
new
(
current_user
,
args
).
execute
.
preload
(
:assignees
,
:labels
,
:notes
)
.
preload
(
:assignees
,
:labels
,
:notes
,
:timelogs
)
issues
.
reorder
(
args
[
:order_by
]
=>
args
[
:sort
])
end
...
...
@@ -68,9 +68,11 @@ module API
get
do
issues
=
find_issues
options
=
{
with:
Entities
::
IssueBasic
,
current_user:
current_user
}
options
[
:issuable_metadata
]
=
issuable_meta_data
(
issues
,
'Issue'
)
options
=
{
with:
Entities
::
IssueBasic
,
current_user:
current_user
,
issuable_metadata:
issuable_meta_data
(
issues
,
'Issue'
)
}
present
paginate
(
issues
),
options
end
...
...
@@ -93,9 +95,11 @@ module API
issues
=
find_issues
(
group_id:
group
.
id
)
options
=
{
with:
Entities
::
IssueBasic
,
current_user:
current_user
}
options
[
:issuable_metadata
]
=
issuable_meta_data
(
issues
,
'Issue'
)
options
=
{
with:
Entities
::
IssueBasic
,
current_user:
current_user
,
issuable_metadata:
issuable_meta_data
(
issues
,
'Issue'
)
}
present
paginate
(
issues
),
options
end
...
...
@@ -120,10 +124,12 @@ module API
issues
=
find_issues
(
project_id:
project
.
id
)
options
=
{
with:
Entities
::
IssueBasic
,
options
=
{
with:
Entities
::
IssueBasic
,
current_user:
current_user
,
project:
user_project
}
options
[
:issuable_metadata
]
=
issuable_meta_data
(
issues
,
'Issue'
)
project:
user_project
,
issuable_metadata:
issuable_meta_data
(
issues
,
'Issue'
)
}
present
paginate
(
issues
),
options
end
...
...
lib/api/merge_requests.rb
View file @
749c3893
...
...
@@ -21,7 +21,7 @@ module API
return
merge_requests
if
args
[
:view
]
==
'simple'
merge_requests
.
preload
(
:notes
,
:author
,
:assignee
,
:milestone
,
:merge_request_diff
,
:labels
)
.
preload
(
:notes
,
:author
,
:assignee
,
:milestone
,
:merge_request_diff
,
:labels
,
:timelogs
)
end
params
:merge_requests_params
do
...
...
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