Merge pull request #51 from sschneid/round_dashboard_capacity_percent

Round capacity percentage to 1 decimal place
This commit is contained in:
Roger Ignazio 2015-02-20 14:16:31 -08:00
commit 44c917b50e
2 changed files with 4 additions and 4 deletions

View file

@ -186,7 +186,7 @@ module Vmpooler
result[:status] = 0
end
result[:capacity_percent] = (result[:capacity_current].to_f / result[:capacity_total].to_f) * 100.0
result[:capacity_percent] = ((result[:capacity_current].to_f / result[:capacity_total].to_f) * 100.0).round(1)
result[:cloning] = $redis.get('vmpooler__tasks__clone')
result[:booting] = result[:pending].to_i - result[:cloning].to_i
@ -195,10 +195,10 @@ module Vmpooler
result[:clone_total] = $redis.hlen('vmpooler__clone__' + Date.today.to_s)
if result[:clone_total] > 0
result[:clone_average] = $redis.hvals('vmpooler__clone__' + Date.today.to_s).map(&:to_f).reduce(:+) / result[:clone_total]
result[:clone_average] = ($redis.hvals('vmpooler__clone__' + Date.today.to_s).map(&:to_f).reduce(:+) / result[:clone_total]).round(1)
end
result[:uptime] = Time.now - $config[:uptime] if $config[:uptime]
result[:uptime] = (Time.now - $config[:uptime]).round(1) if $config[:uptime]
JSON.pretty_generate(Hash[result.sort_by { |k, _v| k }])
end

View file

@ -96,7 +96,7 @@ d3.json( numbers_url,
stats_vmpooler_numbers__svg[ 'clone_average' ]
.append( 'text' )
.text(
( stats_vmpooler_numbers__data__live[ 'clone_average' ].toFixed(1) + 's' )
( stats_vmpooler_numbers__data__live[ 'clone_average' ] + 's' )
)
.attr( {
'text-anchor': 'end',