Add count suffix to GeoNodeStatus attributes

parent 8bf2bcdf
......@@ -11,33 +11,33 @@ class GeoNodeStatus
health.blank?
end
def repositories
@repositories ||= Project.count
def repositories_count
@repositories_count ||= Project.count
end
def repositories=(value)
@repositories = value.to_i
def repositories_count=(value)
@repositories_count = value.to_i
end
def repositories_synced
@repositories_synced ||= Geo::ProjectRegistry.synced.count
def repositories_synced_count
@repositories_synced_count ||= Geo::ProjectRegistry.synced.count
end
def repositories_synced=(value)
@repositories_synced = value.to_i
def repositories_synced_count=(value)
@repositories_synced_count = value.to_i
end
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
def repositories_failed
@repositories_failed ||= Geo::ProjectRegistry.failed.count
def repositories_failed_count
@repositories_failed_count ||= Geo::ProjectRegistry.failed.count
end
def repositories_failed=(value)
@repositories_failed = value.to_i
def repositories_failed_count=(value)
@repositories_failed_count = value.to_i
end
end
class GeoNodePresenter < Gitlab::View::Presenter::Delegated
presents :geo_node
delegate :healthy?, :health, :repositories, :repositories_synced,
:repositories_synced_in_percentage, :repositories_failed,
delegate :healthy?, :health, :repositories_count, :repositories_synced_count,
:repositories_synced_in_percentage, :repositories_failed_count,
to: :status
private
......
......@@ -2,7 +2,7 @@ module Geo
class NodeStatusService
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
default_timeout Gitlab.config.gitlab.geo_status_timeout
......
......@@ -26,10 +26,10 @@
- else
%p
%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
%span.help-block
Repositories failed: #{node.repositories_failed}
Repositories failed: #{node.repositories_failed_count}
%p
%span.help-block= node.healthy? ? 'No Health Problems Detected' : node.health
......
......@@ -771,9 +771,9 @@ module API
class GeoNodeStatus < Grape::Entity
expose :health
expose :repositories
expose :repositories_synced
expose :repositories_failed
expose :repositories_count
expose :repositories_synced_count
expose :repositories_failed_count
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