Add count suffix to GeoNodeStatus attributes

parent 8bf2bcdf
...@@ -11,33 +11,33 @@ class GeoNodeStatus ...@@ -11,33 +11,33 @@ class GeoNodeStatus
health.blank? health.blank?
end end
def repositories def repositories_count
@repositories ||= Project.count @repositories_count ||= Project.count
end end
def repositories=(value) def repositories_count=(value)
@repositories = value.to_i @repositories_count = value.to_i
end end
def repositories_synced def repositories_synced_count
@repositories_synced ||= Geo::ProjectRegistry.synced.count @repositories_synced_count ||= Geo::ProjectRegistry.synced.count
end end
def repositories_synced=(value) def repositories_synced_count=(value)
@repositories_synced = value.to_i @repositories_synced_count = value.to_i
end end
def repositories_synced_in_percentage def repositories_synced_in_percentage
return 0 if repositories.zero? return 0 if repositories_count.zero?
(repositories_synced.to_f / repositories.to_f) * 100.0 (repositories_synced_count.to_f / repositories_count.to_f) * 100.0
end end
def repositories_failed def repositories_failed_count
@repositories_failed ||= Geo::ProjectRegistry.failed.count @repositories_failed_count ||= Geo::ProjectRegistry.failed.count
end end
def repositories_failed=(value) def repositories_failed_count=(value)
@repositories_failed = value.to_i @repositories_failed_count = value.to_i
end end
end end
class GeoNodePresenter < Gitlab::View::Presenter::Delegated class GeoNodePresenter < Gitlab::View::Presenter::Delegated
presents :geo_node presents :geo_node
delegate :healthy?, :health, :repositories, :repositories_synced, delegate :healthy?, :health, :repositories_count, :repositories_synced_count,
:repositories_synced_in_percentage, :repositories_failed, :repositories_synced_in_percentage, :repositories_failed_count,
to: :status to: :status
private private
......
...@@ -2,7 +2,7 @@ module Geo ...@@ -2,7 +2,7 @@ module Geo
class NodeStatusService class NodeStatusService
include HTTParty include HTTParty
KEYS = %w(health repositories repositories_synced repositories_failed).freeze KEYS = %w(health repositories_count repositories_synced_count repositories_failed_count).freeze
# HTTParty timeout # HTTParty timeout
default_timeout Gitlab.config.gitlab.geo_status_timeout default_timeout Gitlab.config.gitlab.geo_status_timeout
......
...@@ -26,10 +26,10 @@ ...@@ -26,10 +26,10 @@
- else - else
%p %p
%span.help-block %span.help-block
Repositories synced: #{node.repositories_synced}/#{node.repositories} (#{number_to_percentage(node.repositories_synced_in_percentage, precision: 2)}) Repositories synced: #{node.repositories_synced_count}/#{node.repositories_count} (#{number_to_percentage(node.repositories_synced_in_percentage, precision: 2)})
%p %p
%span.help-block %span.help-block
Repositories failed: #{node.repositories_failed} Repositories failed: #{node.repositories_failed_count}
%p %p
%span.help-block= node.healthy? ? 'No Health Problems Detected' : node.health %span.help-block= node.healthy? ? 'No Health Problems Detected' : node.health
......
...@@ -771,9 +771,9 @@ module API ...@@ -771,9 +771,9 @@ module API
class GeoNodeStatus < Grape::Entity class GeoNodeStatus < Grape::Entity
expose :health expose :health
expose :repositories expose :repositories_count
expose :repositories_synced expose :repositories_synced_count
expose :repositories_failed expose :repositories_failed_count
end end
end end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment