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
40144ebf
Commit
40144ebf
authored
Mar 24, 2020
by
Rajendra Kadam
Committed by
Peter Leitzen
Mar 24, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Separate code review, design, group module into own module files
parent
8f75140b
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
131 additions
and
78 deletions
+131
-78
ee/changelogs/unreleased/refactoring-ee-entities-15.yml
ee/changelogs/unreleased/refactoring-ee-entities-15.yml
+5
-0
ee/lib/ee/api/entities.rb
ee/lib/ee/api/entities.rb
+0
-78
ee/lib/ee/api/entities/analytics/code_review/merge_request.rb
...ib/ee/api/entities/analytics/code_review/merge_request.rb
+47
-0
ee/lib/ee/api/entities/analytics/group_activity/issues_count.rb
.../ee/api/entities/analytics/group_activity/issues_count.rb
+15
-0
ee/lib/ee/api/entities/analytics/group_activity/merge_requests_count.rb
...entities/analytics/group_activity/merge_requests_count.rb
+15
-0
ee/lib/ee/api/entities/design_management/design.rb
ee/lib/ee/api/entities/design_management/design.rb
+18
-0
ee/lib/ee/api/entities/issue_basic.rb
ee/lib/ee/api/entities/issue_basic.rb
+15
-0
ee/lib/ee/api/entities/protected_branch.rb
ee/lib/ee/api/entities/protected_branch.rb
+16
-0
No files found.
ee/changelogs/unreleased/refactoring-ee-entities-15.yml
0 → 100644
View file @
40144ebf
---
title
:
Separate code review, design and group modules into own class files
merge_request
:
27860
author
:
Rajendra Kadam
type
:
added
ee/lib/ee/api/entities.rb
View file @
40144ebf
...
@@ -3,37 +3,9 @@
...
@@ -3,37 +3,9 @@
module
EE
module
EE
module
API
module
API
module
Entities
module
Entities
module
ProtectedBranch
extend
ActiveSupport
::
Concern
prepended
do
expose
:unprotect_access_levels
,
using:
::
API
::
Entities
::
ProtectedRefAccess
expose
:code_owner_approval_required
end
end
module
IssueBasic
extend
ActiveSupport
::
Concern
prepended
do
expose
:weight
,
if:
->
(
issue
,
_
)
{
issue
.
supports_weight?
}
end
end
########################
########################
# EE-specific entities #
# EE-specific entities #
########################
########################
module
DesignManagement
class
Design
<
Grape
::
Entity
expose
:id
expose
:project_id
expose
:filename
expose
:image_url
do
|
design
|
::
Gitlab
::
UrlBuilder
.
build
(
design
)
end
end
end
module
Nuget
module
Nuget
class
ServiceIndex
<
Grape
::
Entity
class
ServiceIndex
<
Grape
::
Entity
expose
:version
expose
:version
...
@@ -96,56 +68,6 @@ module EE
...
@@ -96,56 +68,6 @@ module EE
expose
:data
,
using:
EE
::
API
::
Entities
::
Nuget
::
SearchResult
expose
:data
,
using:
EE
::
API
::
Entities
::
Nuget
::
SearchResult
end
end
end
end
module
Analytics
module
CodeReview
class
MergeRequest
<
::
API
::
Entities
::
MergeRequestSimple
expose
:milestone
,
using:
::
API
::
Entities
::
Milestone
expose
:author
,
using:
::
API
::
Entities
::
UserBasic
expose
:approved_by_users
,
as: :approved_by
,
using:
::
API
::
Entities
::
UserBasic
expose
:notes_count
do
|
mr
|
if
options
[
:issuable_metadata
]
# Avoids an N+1 query when metadata is included
options
[
:issuable_metadata
][
mr
.
id
].
user_notes_count
else
mr
.
notes
.
user
.
count
end
end
expose
:review_time
do
|
mr
|
time
=
mr
.
metrics
.
review_time
next
unless
time
(
time
/
ActiveSupport
::
Duration
::
SECONDS_PER_HOUR
).
floor
end
expose
:diff_stats
private
# rubocop: disable CodeReuse/ActiveRecord
def
diff_stats
result
=
{
additions:
object
.
diffs
.
diff_files
.
sum
(
&
:added_lines
),
deletions:
object
.
diffs
.
diff_files
.
sum
(
&
:removed_lines
),
commits_count:
object
.
commits_count
}
result
[
:total
]
=
result
[
:additions
]
+
result
[
:deletions
]
result
end
# rubocop: enable CodeReuse/ActiveRecord
end
end
module
GroupActivity
class
IssuesCount
<
Grape
::
Entity
expose
:issues_count
end
class
MergeRequestsCount
<
Grape
::
Entity
expose
:merge_requests_count
end
end
end
end
end
end
end
end
end
ee/lib/ee/api/entities/analytics/code_review/merge_request.rb
0 → 100644
View file @
40144ebf
# frozen_string_literal: true
module
EE
module
API
module
Entities
module
Analytics
module
CodeReview
class
MergeRequest
<
::
API
::
Entities
::
MergeRequestSimple
expose
:milestone
,
using:
::
API
::
Entities
::
Milestone
expose
:author
,
using:
::
API
::
Entities
::
UserBasic
expose
:approved_by_users
,
as: :approved_by
,
using:
::
API
::
Entities
::
UserBasic
expose
:notes_count
do
|
mr
|
if
options
[
:issuable_metadata
]
# Avoids an N+1 query when metadata is included
options
[
:issuable_metadata
][
mr
.
id
].
user_notes_count
else
mr
.
notes
.
user
.
count
end
end
expose
:review_time
do
|
mr
|
time
=
mr
.
metrics
.
review_time
next
unless
time
(
time
/
ActiveSupport
::
Duration
::
SECONDS_PER_HOUR
).
floor
end
expose
:diff_stats
private
# rubocop: disable CodeReuse/ActiveRecord
def
diff_stats
result
=
{
additions:
object
.
diffs
.
diff_files
.
sum
(
&
:added_lines
),
deletions:
object
.
diffs
.
diff_files
.
sum
(
&
:removed_lines
),
commits_count:
object
.
commits_count
}
result
[
:total
]
=
result
[
:additions
]
+
result
[
:deletions
]
result
end
# rubocop: enable CodeReuse/ActiveRecord
end
end
end
end
end
end
ee/lib/ee/api/entities/analytics/group_activity/issues_count.rb
0 → 100644
View file @
40144ebf
# frozen_string_literal: true
module
EE
module
API
module
Entities
module
Analytics
module
GroupActivity
class
IssuesCount
<
Grape
::
Entity
expose
:issues_count
end
end
end
end
end
end
ee/lib/ee/api/entities/analytics/group_activity/merge_requests_count.rb
0 → 100644
View file @
40144ebf
# frozen_string_literal: true
module
EE
module
API
module
Entities
module
Analytics
module
GroupActivity
class
MergeRequestsCount
<
Grape
::
Entity
expose
:merge_requests_count
end
end
end
end
end
end
ee/lib/ee/api/entities/design_management/design.rb
0 → 100644
View file @
40144ebf
# frozen_string_literal: true
module
EE
module
API
module
Entities
module
DesignManagement
class
Design
<
Grape
::
Entity
expose
:id
expose
:project_id
expose
:filename
expose
:image_url
do
|
design
|
::
Gitlab
::
UrlBuilder
.
build
(
design
)
end
end
end
end
end
end
ee/lib/ee/api/entities/issue_basic.rb
0 → 100644
View file @
40144ebf
# frozen_string_literal: true
module
EE
module
API
module
Entities
module
IssueBasic
extend
ActiveSupport
::
Concern
prepended
do
expose
:weight
,
if:
->
(
issue
,
_
)
{
issue
.
supports_weight?
}
end
end
end
end
end
ee/lib/ee/api/entities/protected_branch.rb
0 → 100644
View file @
40144ebf
# frozen_string_literal: true
module
EE
module
API
module
Entities
module
ProtectedBranch
extend
ActiveSupport
::
Concern
prepended
do
expose
:unprotect_access_levels
,
using:
::
API
::
Entities
::
ProtectedRefAccess
expose
:code_owner_approval_required
end
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