city-watch 0.6.6 → 0.6.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -26,14 +26,15 @@ module Reader
26
26
 
27
27
  def sparkline_image_tags
28
28
  data_sets.map do |set|
29
- [set.to_sym, sparkline_img_tag(get_data_set(set).map {|(tm,val)| val })]
30
- end
29
+ dat = get_data_set(set)
30
+ [set.to_sym, dat.length > 1 ? sparkline_img_tag(dat.map {|(tm,val)| val }, set) : nil]
31
+ end.select {|(name,tag)| !tag.nil? }
31
32
  end
32
33
 
33
- def get_data_set(data_set_name,s_time=(Time.now - (60*60*12)),e_time=Time.now)
34
- CityWatch.redis.zrevrangebyscore(data_set_key(data_set_name), s_time.to_i, e_time.to_i, :with_scores => true).map do |(val,score)|
34
+ def get_data_set(data_set_name,s_time=(Time.now - (60*60*4)),e_time=Time.now)
35
+ CityWatch.redis.zrevrangebyscore(data_set_key(data_set_name), e_time.to_i, s_time.to_i, :with_scores => true).map do |(val,score)|
35
36
  timestamp,value = val.split(",")
36
- [Time.at(timestamp.to_i), value]
37
+ [Time.at(timestamp.to_i), Float(value)]
37
38
  end
38
39
  end
39
40
 
@@ -50,11 +51,13 @@ module Reader
50
51
  end
51
52
 
52
53
  def sparkline(dat)
53
- Base64.encode64(Spark.smooth(dat, :has_min => true, :has_max => true, :height => 14, :step => 4)).gsub("\n",'')
54
+ require 'base64'
55
+ require 'city_watch/util/spark_pr'
56
+ Base64.encode64(Spark.smooth(dat, :height => 14, :step => 4).to_png).gsub("\n",'')
54
57
  end
55
58
 
56
- def sparkline_img_tag(dat)
57
- "<img src=\"data:image/png;base64,#{sparkline(dat)}\"/>"
59
+ def sparkline_img_tag(dat,alt="")
60
+ "<img src=\"data:image/png;base64,#{sparkline(dat)}\" alt=\"#{alt}\" title=\"#{alt}\"/>"
58
61
  end
59
62
 
60
63
  def key(more)
data/lib/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module CityWatch
2
- VERSION = "0.6.6"
2
+ VERSION = "0.6.7"
3
3
  end
@@ -1,2 +1,2 @@
1
1
  <h4><%=@name%></h4>
2
- <strong>Root FS usage: </strong><%=@current_data%>
2
+ <strong>Root FS usage: </strong><%=@current_data%>&nbsp;<%= sparkline_image_tags.map {|(name,tag)| tag }.join("&nbsp;")%>
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: city-watch
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.6
4
+ version: 0.6.7
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: