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
bbe0e331
Commit
bbe0e331
authored
Apr 05, 2017
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add attachments synced status to each node on Geo nodes page
parent
7a0da750
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
71 additions
and
0 deletions
+71
-0
app/assets/javascripts/geo_nodes.js
app/assets/javascripts/geo_nodes.js
+2
-0
app/models/geo_node_status.rb
app/models/geo_node_status.rb
+20
-0
app/serializers/geo_node_status_entity.rb
app/serializers/geo_node_status_entity.rb
+6
-0
app/services/geo/node_status_service.rb
app/services/geo/node_status_service.rb
+2
-0
app/views/admin/geo_nodes/index.html.haml
app/views/admin/geo_nodes/index.html.haml
+4
-0
spec/controllers/admin/geo_nodes_controller_spec.rb
spec/controllers/admin/geo_nodes_controller_spec.rb
+2
-0
spec/fixtures/api/schemas/geo_node_status.json
spec/fixtures/api/schemas/geo_node_status.json
+3
-0
spec/models/geo_node_status_spec.rb
spec/models/geo_node_status_spec.rb
+21
-0
spec/serializers/geo_node_status_entity_spec.rb
spec/serializers/geo_node_status_entity_spec.rb
+11
-0
No files found.
app/assets/javascripts/geo_nodes.js
View file @
bbe0e331
...
...
@@ -12,6 +12,7 @@ class GeoNodeStatus {
this
.
$repositoriesSynced
=
$
(
'
.js-repositories-synced
'
,
this
.
$status
);
this
.
$repositoriesFailed
=
$
(
'
.js-repositories-failed
'
,
this
.
$status
);
this
.
$lfsObjectsSynced
=
$
(
'
.js-lfs-objects-synced
'
,
this
.
$status
);
this
.
$attachmentsSynced
=
$
(
'
.js-attachments-synced
'
,
this
.
$status
);
this
.
$health
=
$
(
'
.js-health
'
,
this
.
$status
);
this
.
endpoint
=
this
.
$el
.
data
(
'
status-url
'
);
...
...
@@ -31,6 +32,7 @@ class GeoNodeStatus {
this
.
$repositoriesSynced
.
html
(
`
${
status
.
repositories_synced_count
}
/
${
status
.
repositories_count
}
(
${
status
.
repositories_synced_in_percentage
}
)`
);
this
.
$repositoriesFailed
.
html
(
status
.
repositories_failed_count
);
this
.
$lfsObjectsSynced
.
html
(
`
${
status
.
lfs_objects_synced_count
}
/
${
status
.
lfs_objects_count
}
(
${
status
.
lfs_objects_synced_in_percentage
}
)`
);
this
.
$attachmentsSynced
.
html
(
`
${
status
.
attachments_synced_count
}
/
${
status
.
attachments_count
}
(
${
status
.
attachments_synced_in_percentage
}
)`
);
this
.
$health
.
html
(
status
.
health
);
this
.
$status
.
show
();
...
...
app/models/geo_node_status.rb
View file @
bbe0e331
...
...
@@ -60,6 +60,26 @@ class GeoNodeStatus
sync_percentage
(
lfs_objects_count
,
lfs_objects_synced_count
)
end
def
attachments_count
@attachments_count
||=
Upload
.
count
end
def
attachments_count
=
(
value
)
@attachments_count
=
value
.
to_i
end
def
attachments_synced_count
@attachments_synced_count
||=
Geo
::
FileRegistry
.
where
(
file_type:
[
:attachment
,
:avatar
,
:file
]).
count
end
def
attachments_synced_count
=
(
value
)
@attachments_synced_count
=
value
.
to_i
end
def
attachments_synced_in_percentage
sync_percentage
(
attachments_count
,
attachments_synced_count
)
end
private
def
sync_percentage
(
total
,
synced
)
...
...
app/serializers/geo_node_status_entity.rb
View file @
bbe0e331
...
...
@@ -8,6 +8,12 @@ class GeoNodeStatusEntity < Grape::Entity
node
.
healthy?
?
'No Health Problems Detected'
:
node
.
health
end
expose
:attachments_count
expose
:attachments_synced_count
expose
:attachments_synced_in_percentage
do
|
node
|
number_to_percentage
(
node
.
attachments_synced_in_percentage
,
precision:
2
)
end
expose
:lfs_objects_count
expose
:lfs_objects_synced_count
expose
:lfs_objects_synced_in_percentage
do
|
node
|
...
...
app/services/geo/node_status_service.rb
View file @
bbe0e331
...
...
@@ -10,6 +10,8 @@ module Geo
repositories_failed_count
lfs_objects_count
lfs_objects_synced_count
attachments_count
attachments_synced_count
)
.
freeze
def
call
(
geo_node
)
...
...
app/views/admin/geo_nodes/index.html.haml
View file @
bbe0e331
...
...
@@ -37,6 +37,10 @@
%span
.help-block
LFS objects synced:
%span
.js-lfs-objects-synced
%p
%span
.help-block
Attachments synced:
%span
.js-attachments-synced
%p
%span
.help-block.js-health
...
...
spec/controllers/admin/geo_nodes_controller_spec.rb
View file @
bbe0e331
...
...
@@ -213,6 +213,8 @@ describe Admin::GeoNodesController do
GeoNodeStatus
.
new
(
id:
1
,
health:
nil
,
attachments_count:
329
,
attachments_synced_count:
141
,
lfs_objects_count:
256
,
lfs_objects_synced_count:
123
,
repositories_count:
10
,
...
...
spec/fixtures/api/schemas/geo_node_status.json
View file @
bbe0e331
...
...
@@ -16,6 +16,9 @@
"id"
:
{
"type"
:
"integer"
},
"healthy"
:
{
"type"
:
"boolean"
},
"health"
:
{
"type"
:
"string"
},
"attachments_count"
:
{
"type"
:
"integer"
},
"attachments_synced_count"
:
{
"type"
:
"integer"
},
"attachments_synced_in_percentage"
:
{
"type"
:
"string"
},
"lfs_objects_count"
:
{
"type"
:
"integer"
},
"lfs_objects_synced_count"
:
{
"type"
:
"integer"
},
"lfs_objects_synced_in_percentage"
:
{
"type"
:
"string"
},
...
...
spec/models/geo_node_status_spec.rb
View file @
bbe0e331
...
...
@@ -31,6 +31,22 @@ describe GeoNodeStatus, model: true do
end
end
describe
'#attachments_synced_in_percentage'
do
it
'returns 0 when no objects are available'
do
subject
.
attachments_count
=
0
subject
.
attachments_synced_count
=
0
expect
(
subject
.
attachments_synced_in_percentage
).
to
eq
(
0
)
end
it
'returns the right percentage'
do
subject
.
attachments_count
=
4
subject
.
attachments_synced_count
=
1
expect
(
subject
.
attachments_synced_in_percentage
).
to
be_within
(
0.0001
).
of
(
25
)
end
end
describe
'#lfs_objects_synced_in_percentage'
do
it
'returns 0 when no objects are available'
do
subject
.
lfs_objects_count
=
0
...
...
@@ -65,6 +81,8 @@ describe GeoNodeStatus, model: true do
context
'when no values are available'
do
it
'returns 0 for each attribute'
do
subject
.
attachments_count
=
nil
subject
.
attachments_synced_count
=
nil
subject
.
lfs_objects_count
=
nil
subject
.
lfs_objects_synced_count
=
nil
subject
.
repositories_count
=
nil
...
...
@@ -78,6 +96,9 @@ describe GeoNodeStatus, model: true do
expect
(
subject
.
lfs_objects_count
).
to
be_zero
expect
(
subject
.
lfs_objects_synced_count
).
to
be_zero
expect
(
subject
.
lfs_objects_synced_in_percentage
).
to
be_zero
expect
(
subject
.
attachments_count
).
to
be_zero
expect
(
subject
.
attachments_synced_count
).
to
be_zero
expect
(
subject
.
attachments_synced_in_percentage
).
to
be_zero
end
end
end
spec/serializers/geo_node_status_entity_spec.rb
View file @
bbe0e331
...
...
@@ -5,6 +5,8 @@ describe GeoNodeStatusEntity do
GeoNodeStatus
.
new
(
id:
1
,
health:
nil
,
attachments_count:
329
,
attachments_synced_count:
141
,
lfs_objects_count:
256
,
lfs_objects_synced_count:
123
,
repositories_count:
10
,
...
...
@@ -25,6 +27,9 @@ describe GeoNodeStatusEntity do
it
{
is_expected
.
to
have_key
(
:id
)
}
it
{
is_expected
.
to
have_key
(
:healthy
)
}
it
{
is_expected
.
to
have_key
(
:health
)
}
it
{
is_expected
.
to
have_key
(
:attachments_count
)
}
it
{
is_expected
.
to
have_key
(
:attachments_synced_count
)
}
it
{
is_expected
.
to
have_key
(
:attachments_synced_in_percentage
)
}
it
{
is_expected
.
to
have_key
(
:lfs_objects_count
)
}
it
{
is_expected
.
to
have_key
(
:lfs_objects_synced_count
)
}
it
{
is_expected
.
to
have_key
(
:lfs_objects_synced_in_percentage
)
}
...
...
@@ -73,6 +78,12 @@ describe GeoNodeStatusEntity do
end
end
describe
'#attachments_synced_in_percentage'
do
it
'formats as percentage'
do
expect
(
subject
[
:attachments_synced_in_percentage
]).
to
eq
'42.86%'
end
end
describe
'#lfs_objects_synced_in_percentage'
do
it
'formats as percentage'
do
expect
(
subject
[
:lfs_objects_synced_in_percentage
]).
to
eq
'48.05%'
...
...
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