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
ee618868
Commit
ee618868
authored
Mar 06, 2020
by
Rajendra Kadam
Committed by
Rémy Coutable
Mar 06, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Separate geo, subs and npm entities into own class files
parent
9b144771
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
242 additions
and
202 deletions
+242
-202
ee/changelogs/unreleased/refactoring-ee-entities-6.yml
ee/changelogs/unreleased/refactoring-ee-entities-6.yml
+5
-0
ee/lib/ee/api/entities.rb
ee/lib/ee/api/entities.rb
+0
-202
ee/lib/ee/api/entities/geo_node_status.rb
ee/lib/ee/api/entities/geo_node_status.rb
+169
-0
ee/lib/ee/api/entities/gitlab_subscription.rb
ee/lib/ee/api/entities/gitlab_subscription.rb
+30
-0
ee/lib/ee/api/entities/npm_package.rb
ee/lib/ee/api/entities/npm_package.rb
+13
-0
ee/lib/ee/api/entities/npm_package_tag.rb
ee/lib/ee/api/entities/npm_package_tag.rb
+11
-0
ee/lib/ee/api/entities/unleash_feature.rb
ee/lib/ee/api/entities/unleash_feature.rb
+14
-0
No files found.
ee/changelogs/unreleased/refactoring-ee-entities-6.yml
0 → 100644
View file @
ee618868
---
title
:
Separate npm, subs and geo entities into own class file
merge_request
:
26674
author
:
Rajendra Kadam
type
:
added
ee/lib/ee/api/entities.rb
View file @
ee618868
...
...
@@ -492,198 +492,6 @@ module EE
end
end
class
GeoNodeStatus
<
Grape
::
Entity
include
::
API
::
Helpers
::
RelatedResourcesHelpers
include
ActionView
::
Helpers
::
NumberHelper
expose
:geo_node_id
expose
:healthy?
,
as: :healthy
expose
:health
do
|
node
|
node
.
healthy?
?
'Healthy'
:
node
.
health
end
expose
:health_status
expose
:missing_oauth_application
expose
:attachments_count
expose
:attachments_synced_count
expose
:attachments_failed_count
expose
:attachments_synced_missing_on_primary_count
expose
:attachments_synced_in_percentage
do
|
node
|
number_to_percentage
(
node
.
attachments_synced_in_percentage
,
precision:
2
)
end
expose
:db_replication_lag_seconds
expose
:lfs_objects_count
expose
:lfs_objects_synced_count
expose
:lfs_objects_failed_count
expose
:lfs_objects_synced_missing_on_primary_count
expose
:lfs_objects_synced_in_percentage
do
|
node
|
number_to_percentage
(
node
.
lfs_objects_synced_in_percentage
,
precision:
2
)
end
expose
:job_artifacts_count
expose
:job_artifacts_synced_count
expose
:job_artifacts_failed_count
expose
:job_artifacts_synced_missing_on_primary_count
expose
:job_artifacts_synced_in_percentage
do
|
node
|
number_to_percentage
(
node
.
job_artifacts_synced_in_percentage
,
precision:
2
)
end
expose
:container_repositories_count
expose
:container_repositories_synced_count
expose
:container_repositories_failed_count
expose
:container_repositories_synced_in_percentage
do
|
node
|
number_to_percentage
(
node
.
container_repositories_synced_in_percentage
,
precision:
2
)
end
expose
:design_repositories_count
expose
:design_repositories_synced_count
expose
:design_repositories_failed_count
expose
:design_repositories_synced_in_percentage
do
|
node
|
number_to_percentage
(
node
.
design_repositories_synced_in_percentage
,
precision:
2
)
end
expose
:projects_count
expose
:repositories_failed_count
expose
:repositories_synced_count
expose
:repositories_synced_in_percentage
do
|
node
|
number_to_percentage
(
node
.
repositories_synced_in_percentage
,
precision:
2
)
end
expose
:wikis_failed_count
expose
:wikis_synced_count
expose
:wikis_synced_in_percentage
do
|
node
|
number_to_percentage
(
node
.
wikis_synced_in_percentage
,
precision:
2
)
end
expose
:repository_verification_enabled
expose
:repositories_checksummed_count
expose
:repositories_checksum_failed_count
expose
:repositories_checksummed_in_percentage
do
|
node
|
number_to_percentage
(
node
.
repositories_checksummed_in_percentage
,
precision:
2
)
end
expose
:wikis_checksummed_count
expose
:wikis_checksum_failed_count
expose
:wikis_checksummed_in_percentage
do
|
node
|
number_to_percentage
(
node
.
wikis_checksummed_in_percentage
,
precision:
2
)
end
expose
:repositories_verification_failed_count
expose
:repositories_verified_count
expose
:repositories_verified_in_percentage
do
|
node
|
number_to_percentage
(
node
.
repositories_verified_in_percentage
,
precision:
2
)
end
expose
:repositories_checksum_mismatch_count
expose
:wikis_verification_failed_count
expose
:wikis_verified_count
expose
:wikis_verified_in_percentage
do
|
node
|
number_to_percentage
(
node
.
wikis_verified_in_percentage
,
precision:
2
)
end
expose
:wikis_checksum_mismatch_count
expose
:repositories_retrying_verification_count
expose
:wikis_retrying_verification_count
expose
:replication_slots_count
expose
:replication_slots_used_count
expose
:replication_slots_used_in_percentage
do
|
node
|
number_to_percentage
(
node
.
replication_slots_used_in_percentage
,
precision:
2
)
end
expose
:replication_slots_max_retained_wal_bytes
expose
:repositories_checked_count
expose
:repositories_checked_failed_count
expose
:repositories_checked_in_percentage
do
|
node
|
number_to_percentage
(
node
.
repositories_checked_in_percentage
,
precision:
2
)
end
expose
:last_event_id
expose
:last_event_timestamp
expose
:cursor_last_event_id
expose
:cursor_last_event_timestamp
expose
:last_successful_status_check_timestamp
expose
:version
expose
:revision
expose
:selective_sync_type
# Deprecated: remove in API v5. We use selective_sync_type instead now.
expose
:namespaces
,
using:
::
API
::
Entities
::
NamespaceBasic
expose
:updated_at
# We load GeoNodeStatus data in two ways:
#
# 1. Directly by asking a Geo node via an API call
# 2. Via cached state in the database
#
# We don't yet cached the state of the shard information in the database, so if
# we don't have this information omit from the serialization entirely.
expose
:storage_shards
,
using:
StorageShardEntity
,
if:
->
(
status
,
options
)
do
status
.
storage_shards
.
present?
end
expose
:storage_shards_match?
,
as: :storage_shards_match
expose
:_links
do
expose
:self
do
|
geo_node_status
|
expose_url
api_v4_geo_nodes_status_path
(
id:
geo_node_status
.
geo_node_id
)
end
expose
:node
do
|
geo_node_status
|
expose_url
api_v4_geo_nodes_path
(
id:
geo_node_status
.
geo_node_id
)
end
end
private
def
namespaces
object
.
geo_node
.
namespaces
end
def
missing_oauth_application
object
.
geo_node
.
missing_oauth_application?
end
end
class
UnleashFeature
<
Grape
::
Entity
expose
:name
expose
:description
,
unless:
->
(
feature
)
{
feature
.
description
.
nil?
}
expose
:active
,
as: :enabled
expose
:strategies
end
class
GitlabSubscription
<
Grape
::
Entity
expose
:plan
do
expose
:plan_name
,
as: :code
expose
:plan_title
,
as: :name
expose
:trial
expose
:auto_renew
expose
:upgradable?
,
as: :upgradable
end
expose
:usage
do
expose
:seats
,
as: :seats_in_subscription
expose
:seats_in_use
expose
:max_seats_used
expose
:seats_owed
end
expose
:billing
do
expose
:start_date
,
as: :subscription_start_date
expose
:end_date
,
as: :subscription_end_date
expose
:trial_ends_on
end
end
module
ConanPackage
class
ConanPackageManifest
<
Grape
::
Entity
expose
:package_urls
,
merge:
true
...
...
@@ -769,16 +577,6 @@ module EE
end
end
class
NpmPackage
<
Grape
::
Entity
expose
:name
expose
:versions
expose
:dist_tags
,
as:
'dist-tags'
end
class
NpmPackageTag
<
Grape
::
Entity
expose
:dist_tags
,
merge:
true
end
module
Analytics
module
CodeReview
class
MergeRequest
<
::
API
::
Entities
::
MergeRequestSimple
...
...
ee/lib/ee/api/entities/geo_node_status.rb
0 → 100644
View file @
ee618868
# frozen_string_literal: true
module
EE
module
API
module
Entities
class
GeoNodeStatus
<
Grape
::
Entity
include
::
API
::
Helpers
::
RelatedResourcesHelpers
include
ActionView
::
Helpers
::
NumberHelper
expose
:geo_node_id
expose
:healthy?
,
as: :healthy
expose
:health
do
|
node
|
node
.
healthy?
?
'Healthy'
:
node
.
health
end
expose
:health_status
expose
:missing_oauth_application
expose
:attachments_count
expose
:attachments_synced_count
expose
:attachments_failed_count
expose
:attachments_synced_missing_on_primary_count
expose
:attachments_synced_in_percentage
do
|
node
|
number_to_percentage
(
node
.
attachments_synced_in_percentage
,
precision:
2
)
end
expose
:db_replication_lag_seconds
expose
:lfs_objects_count
expose
:lfs_objects_synced_count
expose
:lfs_objects_failed_count
expose
:lfs_objects_synced_missing_on_primary_count
expose
:lfs_objects_synced_in_percentage
do
|
node
|
number_to_percentage
(
node
.
lfs_objects_synced_in_percentage
,
precision:
2
)
end
expose
:job_artifacts_count
expose
:job_artifacts_synced_count
expose
:job_artifacts_failed_count
expose
:job_artifacts_synced_missing_on_primary_count
expose
:job_artifacts_synced_in_percentage
do
|
node
|
number_to_percentage
(
node
.
job_artifacts_synced_in_percentage
,
precision:
2
)
end
expose
:container_repositories_count
expose
:container_repositories_synced_count
expose
:container_repositories_failed_count
expose
:container_repositories_synced_in_percentage
do
|
node
|
number_to_percentage
(
node
.
container_repositories_synced_in_percentage
,
precision:
2
)
end
expose
:design_repositories_count
expose
:design_repositories_synced_count
expose
:design_repositories_failed_count
expose
:design_repositories_synced_in_percentage
do
|
node
|
number_to_percentage
(
node
.
design_repositories_synced_in_percentage
,
precision:
2
)
end
expose
:projects_count
expose
:repositories_failed_count
expose
:repositories_synced_count
expose
:repositories_synced_in_percentage
do
|
node
|
number_to_percentage
(
node
.
repositories_synced_in_percentage
,
precision:
2
)
end
expose
:wikis_failed_count
expose
:wikis_synced_count
expose
:wikis_synced_in_percentage
do
|
node
|
number_to_percentage
(
node
.
wikis_synced_in_percentage
,
precision:
2
)
end
expose
:repository_verification_enabled
expose
:repositories_checksummed_count
expose
:repositories_checksum_failed_count
expose
:repositories_checksummed_in_percentage
do
|
node
|
number_to_percentage
(
node
.
repositories_checksummed_in_percentage
,
precision:
2
)
end
expose
:wikis_checksummed_count
expose
:wikis_checksum_failed_count
expose
:wikis_checksummed_in_percentage
do
|
node
|
number_to_percentage
(
node
.
wikis_checksummed_in_percentage
,
precision:
2
)
end
expose
:repositories_verification_failed_count
expose
:repositories_verified_count
expose
:repositories_verified_in_percentage
do
|
node
|
number_to_percentage
(
node
.
repositories_verified_in_percentage
,
precision:
2
)
end
expose
:repositories_checksum_mismatch_count
expose
:wikis_verification_failed_count
expose
:wikis_verified_count
expose
:wikis_verified_in_percentage
do
|
node
|
number_to_percentage
(
node
.
wikis_verified_in_percentage
,
precision:
2
)
end
expose
:wikis_checksum_mismatch_count
expose
:repositories_retrying_verification_count
expose
:wikis_retrying_verification_count
expose
:replication_slots_count
expose
:replication_slots_used_count
expose
:replication_slots_used_in_percentage
do
|
node
|
number_to_percentage
(
node
.
replication_slots_used_in_percentage
,
precision:
2
)
end
expose
:replication_slots_max_retained_wal_bytes
expose
:repositories_checked_count
expose
:repositories_checked_failed_count
expose
:repositories_checked_in_percentage
do
|
node
|
number_to_percentage
(
node
.
repositories_checked_in_percentage
,
precision:
2
)
end
expose
:last_event_id
expose
:last_event_timestamp
expose
:cursor_last_event_id
expose
:cursor_last_event_timestamp
expose
:last_successful_status_check_timestamp
expose
:version
expose
:revision
expose
:selective_sync_type
# Deprecated: remove in API v5. We use selective_sync_type instead now.
expose
:namespaces
,
using:
::
API
::
Entities
::
NamespaceBasic
expose
:updated_at
# We load GeoNodeStatus data in two ways:
#
# 1. Directly by asking a Geo node via an API call
# 2. Via cached state in the database
#
# We don't yet cached the state of the shard information in the database, so if
# we don't have this information omit from the serialization entirely.
expose
:storage_shards
,
using:
StorageShardEntity
,
if:
->
(
status
,
options
)
do
status
.
storage_shards
.
present?
end
expose
:storage_shards_match?
,
as: :storage_shards_match
expose
:_links
do
expose
:self
do
|
geo_node_status
|
expose_url
api_v4_geo_nodes_status_path
(
id:
geo_node_status
.
geo_node_id
)
end
expose
:node
do
|
geo_node_status
|
expose_url
api_v4_geo_nodes_path
(
id:
geo_node_status
.
geo_node_id
)
end
end
private
def
namespaces
object
.
geo_node
.
namespaces
end
def
missing_oauth_application
object
.
geo_node
.
missing_oauth_application?
end
end
end
end
end
ee/lib/ee/api/entities/gitlab_subscription.rb
0 → 100644
View file @
ee618868
# frozen_string_literal: true
module
EE
module
API
module
Entities
class
GitlabSubscription
<
Grape
::
Entity
expose
:plan
do
expose
:plan_name
,
as: :code
expose
:plan_title
,
as: :name
expose
:trial
expose
:auto_renew
expose
:upgradable?
,
as: :upgradable
end
expose
:usage
do
expose
:seats
,
as: :seats_in_subscription
expose
:seats_in_use
expose
:max_seats_used
expose
:seats_owed
end
expose
:billing
do
expose
:start_date
,
as: :subscription_start_date
expose
:end_date
,
as: :subscription_end_date
expose
:trial_ends_on
end
end
end
end
end
ee/lib/ee/api/entities/npm_package.rb
0 → 100644
View file @
ee618868
# frozen_string_literal: true
module
EE
module
API
module
Entities
class
NpmPackage
<
Grape
::
Entity
expose
:name
expose
:versions
expose
:dist_tags
,
as:
'dist-tags'
end
end
end
end
ee/lib/ee/api/entities/npm_package_tag.rb
0 → 100644
View file @
ee618868
# frozen_string_literal: true
module
EE
module
API
module
Entities
class
NpmPackageTag
<
Grape
::
Entity
expose
:dist_tags
,
merge:
true
end
end
end
end
ee/lib/ee/api/entities/unleash_feature.rb
0 → 100644
View file @
ee618868
# frozen_string_literal: true
module
EE
module
API
module
Entities
class
UnleashFeature
<
Grape
::
Entity
expose
:name
expose
:description
,
unless:
->
(
feature
)
{
feature
.
description
.
nil?
}
expose
:active
,
as: :enabled
expose
:strategies
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