lib/ustate/dash/helper/renderer.rb in ustate-client-0.0.4 vs lib/ustate/dash/helper/renderer.rb in ustate-client-0.0.5

- old
+ new

@@ -123,27 +123,37 @@ names end.merge o[:service_names] # Compute maximum for each service maxima = if o[:global_maximum] - max = states.map(&:metric).max + max = states.map(&:metric).compact.max services.inject({}) do |m, s| m[s] = max m end.merge o[:maxima] else states.inject(Hash.new(0)) do |m, s| - m[s.service] = [s.metric, m[s.service]].max + if s.metric + m[s.service] = [s.metric, m[s.service]].max + end m end.merge o[:maxima] end # Compute union of all hosts for these states, if no # list of hosts explicitly given. hosts = o[:hosts] || states.map do |state| state.host - end.compact - hosts = hosts.uniq.sort + end + hosts = hosts.uniq.sort { |a, b| + if !a + -1 + elsif !b + 1 + else + a <=> b + end + } # Construct index by = states.inject({}) do |index, s| index[[s.host, s.service]] = s index