grapher 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/app/helpers/grapher/application_helper.rb +20 -12
- data/lib/grapher/version.rb +1 -1
- metadata +2 -2
@@ -6,21 +6,29 @@ module Grapher
|
|
6
6
|
def initialize(time_units, options, block)
|
7
7
|
@time_units = time_units
|
8
8
|
@options = options
|
9
|
-
|
10
|
-
|
11
|
-
if @
|
12
|
-
@strf = "
|
13
|
-
|
9
|
+
@driver = ActiveRecord::Base.connection.instance_values["config"][:adapter]
|
10
|
+
|
11
|
+
if @driver =~ /postgre/
|
12
|
+
@strf = "YYYY-MM-DD"
|
13
|
+
if @time_units.downcase == "hour"
|
14
|
+
@strf = "%Y-%m-%d %H:00"
|
15
|
+
elsif @time_units.downcase == "month"
|
16
|
+
@strf = "YYYY-MM-1"
|
17
|
+
end
|
18
|
+
else
|
14
19
|
@strf = "%Y-%m-%d"
|
15
|
-
|
16
|
-
|
20
|
+
if @time_units.downcase == "hour"
|
21
|
+
@strf = "%Y-%m-%d %H:00"
|
22
|
+
elsif @time_units.downcase == "month"
|
23
|
+
@strf = "%Y-%m-1"
|
24
|
+
end
|
17
25
|
end
|
18
26
|
|
19
27
|
block.call(self)
|
20
28
|
end
|
21
29
|
|
22
30
|
def line(relation, options={})
|
23
|
-
|
31
|
+
|
24
32
|
|
25
33
|
@data ||= []
|
26
34
|
@labels ||= []
|
@@ -28,11 +36,11 @@ module Grapher
|
|
28
36
|
label = options[:label] || "Value"
|
29
37
|
@labels << label
|
30
38
|
|
31
|
-
if driver =~ /mysql/
|
32
|
-
relation = relation.group("DATE_FORMAT(#{@column}, '#{@strf}')")
|
33
|
-
elsif driver =~ /postgre/
|
39
|
+
if @driver =~ /mysql/
|
34
40
|
relation = relation.group("DATE_FORMAT(#{@column}, '#{@strf}')")
|
35
|
-
elsif driver =~ /
|
41
|
+
elsif @driver =~ /postgre/
|
42
|
+
relation = relation.group("to_char(#{@column}, '#{@strf}')")
|
43
|
+
elsif @driver =~ /sqlite/
|
36
44
|
relation = relation.group("STRFTIME('#{@strf}', #{@column})")
|
37
45
|
end
|
38
46
|
|
data/lib/grapher/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: grapher
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-11-
|
12
|
+
date: 2012-11-30 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|