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
5f2444bc
Commit
5f2444bc
authored
Jan 30, 2020
by
Rajendra Kadam
Committed by
Stan Hu
Jan 30, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Separate group and project stats entities into own classes
parent
28f2ab29
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
131 additions
and
91 deletions
+131
-91
changelogs/unreleased/refactoring-entities-file-6.yml
changelogs/unreleased/refactoring-entities-file-6.yml
+5
-0
lib/api/entities.rb
lib/api/entities.rb
+0
-91
lib/api/entities/access_requester.rb
lib/api/entities/access_requester.rb
+10
-0
lib/api/entities/basic_group_details.rb
lib/api/entities/basic_group_details.rb
+11
-0
lib/api/entities/group.rb
lib/api/entities/group.rb
+36
-0
lib/api/entities/group_detail.rb
lib/api/entities/group_detail.rb
+36
-0
lib/api/entities/member.rb
lib/api/entities/member.rb
+11
-0
lib/api/entities/project_daily_fetches.rb
lib/api/entities/project_daily_fetches.rb
+10
-0
lib/api/entities/project_daily_statistics.rb
lib/api/entities/project_daily_statistics.rb
+12
-0
No files found.
changelogs/unreleased/refactoring-entities-file-6.yml
0 → 100644
View file @
5f2444bc
---
title
:
Separate project and group entities into own class files
merge_request
:
24070
author
:
Rajendra Kadam
type
:
added
lib/api/entities.rb
View file @
5f2444bc
...
...
@@ -128,97 +128,6 @@ module API
end
end
class
ProjectDailyFetches
<
Grape
::
Entity
expose
:fetch_count
,
as: :count
expose
:date
end
class
ProjectDailyStatistics
<
Grape
::
Entity
expose
:fetches
do
expose
:total_fetch_count
,
as: :total
expose
:fetches
,
as: :days
,
using:
ProjectDailyFetches
end
end
class
Member
<
Grape
::
Entity
expose
:user
,
merge:
true
,
using:
UserBasic
expose
:access_level
expose
:expires_at
end
class
AccessRequester
<
Grape
::
Entity
expose
:user
,
merge:
true
,
using:
UserBasic
expose
:requested_at
end
class
BasicGroupDetails
<
Grape
::
Entity
expose
:id
expose
:web_url
expose
:name
end
class
Group
<
BasicGroupDetails
expose
:path
,
:description
,
:visibility
expose
:share_with_group_lock
expose
:require_two_factor_authentication
expose
:two_factor_grace_period
expose
:project_creation_level_str
,
as: :project_creation_level
expose
:auto_devops_enabled
expose
:subgroup_creation_level_str
,
as: :subgroup_creation_level
expose
:emails_disabled
expose
:mentions_disabled
expose
:lfs_enabled?
,
as: :lfs_enabled
expose
:avatar_url
do
|
group
,
options
|
group
.
avatar_url
(
only_path:
false
)
end
expose
:request_access_enabled
expose
:full_name
,
:full_path
expose
:parent_id
expose
:custom_attributes
,
using:
'API::Entities::CustomAttribute'
,
if: :with_custom_attributes
expose
:statistics
,
if: :statistics
do
with_options
format_with:
->
(
value
)
{
value
.
to_i
}
do
expose
:storage_size
expose
:repository_size
expose
:wiki_size
expose
:lfs_objects_size
expose
:build_artifacts_size
,
as: :job_artifacts_size
end
end
end
class
GroupDetail
<
Group
expose
:runners_token
,
if:
lambda
{
|
group
,
options
|
options
[
:user_can_admin_group
]
}
expose
:projects
,
using:
Entities
::
Project
do
|
group
,
options
|
projects
=
GroupProjectsFinder
.
new
(
group:
group
,
current_user:
options
[
:current_user
],
options:
{
only_owned:
true
,
limit:
projects_limit
}
).
execute
Entities
::
Project
.
prepare_relation
(
projects
)
end
expose
:shared_projects
,
using:
Entities
::
Project
do
|
group
,
options
|
projects
=
GroupProjectsFinder
.
new
(
group:
group
,
current_user:
options
[
:current_user
],
options:
{
only_shared:
true
,
limit:
projects_limit
}
).
execute
Entities
::
Project
.
prepare_relation
(
projects
)
end
def
projects_limit
if
::
Feature
.
enabled?
(
:limit_projects_in_groups_api
,
default_enabled:
true
)
GroupProjectsFinder
::
DEFAULT_PROJECTS_LIMIT
else
nil
end
end
end
class
DiffRefs
<
Grape
::
Entity
expose
:base_sha
,
:head_sha
,
:start_sha
end
...
...
lib/api/entities/access_requester.rb
0 → 100644
View file @
5f2444bc
# frozen_string_literal: true
module
API
module
Entities
class
AccessRequester
<
Grape
::
Entity
expose
:user
,
merge:
true
,
using:
UserBasic
expose
:requested_at
end
end
end
lib/api/entities/basic_group_details.rb
0 → 100644
View file @
5f2444bc
# frozen_string_literal: true
module
API
module
Entities
class
BasicGroupDetails
<
Grape
::
Entity
expose
:id
expose
:web_url
expose
:name
end
end
end
lib/api/entities/group.rb
0 → 100644
View file @
5f2444bc
# frozen_string_literal: true
module
API
module
Entities
class
Group
<
BasicGroupDetails
expose
:path
,
:description
,
:visibility
expose
:share_with_group_lock
expose
:require_two_factor_authentication
expose
:two_factor_grace_period
expose
:project_creation_level_str
,
as: :project_creation_level
expose
:auto_devops_enabled
expose
:subgroup_creation_level_str
,
as: :subgroup_creation_level
expose
:emails_disabled
expose
:mentions_disabled
expose
:lfs_enabled?
,
as: :lfs_enabled
expose
:avatar_url
do
|
group
,
options
|
group
.
avatar_url
(
only_path:
false
)
end
expose
:request_access_enabled
expose
:full_name
,
:full_path
expose
:parent_id
expose
:custom_attributes
,
using:
'API::Entities::CustomAttribute'
,
if: :with_custom_attributes
expose
:statistics
,
if: :statistics
do
with_options
format_with:
->
(
value
)
{
value
.
to_i
}
do
expose
:storage_size
expose
:repository_size
expose
:wiki_size
expose
:lfs_objects_size
expose
:build_artifacts_size
,
as: :job_artifacts_size
end
end
end
end
end
lib/api/entities/group_detail.rb
0 → 100644
View file @
5f2444bc
# frozen_string_literal: true
module
API
module
Entities
class
GroupDetail
<
Group
expose
:runners_token
,
if:
lambda
{
|
group
,
options
|
options
[
:user_can_admin_group
]
}
expose
:projects
,
using:
Entities
::
Project
do
|
group
,
options
|
projects
=
GroupProjectsFinder
.
new
(
group:
group
,
current_user:
options
[
:current_user
],
options:
{
only_owned:
true
,
limit:
projects_limit
}
).
execute
Entities
::
Project
.
prepare_relation
(
projects
)
end
expose
:shared_projects
,
using:
Entities
::
Project
do
|
group
,
options
|
projects
=
GroupProjectsFinder
.
new
(
group:
group
,
current_user:
options
[
:current_user
],
options:
{
only_shared:
true
,
limit:
projects_limit
}
).
execute
Entities
::
Project
.
prepare_relation
(
projects
)
end
def
projects_limit
if
::
Feature
.
enabled?
(
:limit_projects_in_groups_api
,
default_enabled:
true
)
GroupProjectsFinder
::
DEFAULT_PROJECTS_LIMIT
else
nil
end
end
end
end
end
lib/api/entities/member.rb
0 → 100644
View file @
5f2444bc
# frozen_string_literal: true
module
API
module
Entities
class
Member
<
Grape
::
Entity
expose
:user
,
merge:
true
,
using:
UserBasic
expose
:access_level
expose
:expires_at
end
end
end
lib/api/entities/project_daily_fetches.rb
0 → 100644
View file @
5f2444bc
# frozen_string_literal: true
module
API
module
Entities
class
ProjectDailyFetches
<
Grape
::
Entity
expose
:fetch_count
,
as: :count
expose
:date
end
end
end
lib/api/entities/project_daily_statistics.rb
0 → 100644
View file @
5f2444bc
# frozen_string_literal: true
module
API
module
Entities
class
ProjectDailyStatistics
<
Grape
::
Entity
expose
:fetches
do
expose
:total_fetch_count
,
as: :total
expose
:fetches
,
as: :days
,
using:
ProjectDailyFetches
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