reparty 0.3.1 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- data/History.md +5 -0
- data/lib/reparty/report/active_record.rb +4 -2
- data/lib/reparty/report/sendgrid.rb +1 -1
- data/lib/reparty/report.rb +13 -2
- data/lib/reparty/version.rb +1 -1
- metadata +4 -4
data/History.md
CHANGED
@@ -3,6 +3,7 @@ require 'active_record'
|
|
3
3
|
module Reparty
|
4
4
|
class Report
|
5
5
|
class ActiveRecord < Report
|
6
|
+
@@color_index = 0
|
6
7
|
attr_reader :model, :operation, :field
|
7
8
|
|
8
9
|
def initialize(*args, &block)
|
@@ -27,9 +28,10 @@ module Reparty
|
|
27
28
|
end
|
28
29
|
|
29
30
|
def attach(attachments)
|
30
|
-
@graph =
|
31
|
+
@graph = @operation == :total ? build_daily_area_graph : build_daily_bar_graph
|
31
32
|
|
32
|
-
@graph.data(@model.to_s.pluralize, daily_dataset)
|
33
|
+
@graph.data(@model.to_s.pluralize, daily_dataset, @graph.colors[@@color_index])
|
34
|
+
@@color_index = (@@color_index + 1) % @graph.colors.length
|
33
35
|
|
34
36
|
attachments.inline["#{self.hash}.png"] = @graph.to_blob
|
35
37
|
end
|
data/lib/reparty/report.rb
CHANGED
@@ -16,8 +16,19 @@ module Reparty
|
|
16
16
|
|
17
17
|
protected
|
18
18
|
|
19
|
-
def
|
20
|
-
|
19
|
+
def build_daily_line_graph(start_date=DateTime.now.utc)
|
20
|
+
build_daily_graph(Gruff::Line.new(545), start_date)
|
21
|
+
end
|
22
|
+
|
23
|
+
def build_daily_area_graph(start_date=DateTime.now.utc)
|
24
|
+
build_daily_graph(Gruff::Area.new(545), start_date)
|
25
|
+
end
|
26
|
+
|
27
|
+
def build_daily_bar_graph(start_date=DateTime.now.utc)
|
28
|
+
build_daily_graph(Gruff::Bar.new(545), start_date)
|
29
|
+
end
|
30
|
+
|
31
|
+
def build_daily_graph(g, start_date)
|
21
32
|
g.title = @title
|
22
33
|
g.labels = Hash[*(1..7).map{|x| [x-1, (start_date - (8-x)).strftime("%-m/%-d")] }.flatten]
|
23
34
|
g
|
data/lib/reparty/version.rb
CHANGED
metadata
CHANGED
@@ -2,14 +2,14 @@
|
|
2
2
|
name: reparty
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.3.
|
5
|
+
version: 0.3.2
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Tim Dorr
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-05-
|
12
|
+
date: 2013-05-24 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: railties
|
@@ -289,7 +289,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
289
289
|
- !ruby/object:Gem::Version
|
290
290
|
segments:
|
291
291
|
- 0
|
292
|
-
hash:
|
292
|
+
hash: -1981622501360385862
|
293
293
|
version: '0'
|
294
294
|
none: false
|
295
295
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
@@ -298,7 +298,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
298
298
|
- !ruby/object:Gem::Version
|
299
299
|
segments:
|
300
300
|
- 0
|
301
|
-
hash:
|
301
|
+
hash: -1981622501360385862
|
302
302
|
version: '0'
|
303
303
|
none: false
|
304
304
|
requirements: []
|