g_ruby 0.0.6 → 0.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/g_ruby/analytics.rb +15 -3
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9d4c66b33befa89ea4aa6b22cbae4d35cd82ed60
|
4
|
+
data.tar.gz: c451c48de3905e79524348668721aa9831d515ea
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d7e884830ee87f0629bae61f619465170cc7026e9ed1098dd464f732944d949c77cde05b9d5419bb1dd87f595f4e7c1bf297368fbe1a34feeca0a3e2ee6bf855
|
7
|
+
data.tar.gz: f47a1947f327aeac4f81155170eb3f93fe7d158a41701cea7182d3db96f3671cc49a5e55521617e8dab1c9b64658389c40406fc25a92df29946df0d4ffa32194
|
data/lib/g_ruby/analytics.rb
CHANGED
@@ -119,7 +119,11 @@ class GRuby::Analytics
|
|
119
119
|
d_this = a30[metric].to_i
|
120
120
|
d_last = a60[metric].to_i
|
121
121
|
dd = GRuby::Analytics.generate_delta_explaination(d_this, d_last, refresh)
|
122
|
-
|
122
|
+
if d_last == 0
|
123
|
+
response_obj << {tag: metric.gsub("ga:", ""), val: a0[metric], delta: 0, delta_explaination: dd}
|
124
|
+
else
|
125
|
+
response_obj << {tag: metric.gsub("ga:", ""), val: a0[metric], delta: ((d_this - d_last) * 100 / d_last), delta_explaination: dd}
|
126
|
+
end
|
123
127
|
end
|
124
128
|
elsif dimensions.split(",").count == 1 and metrics.split(",").count == 1
|
125
129
|
a0.each do |i|
|
@@ -132,7 +136,11 @@ class GRuby::Analytics
|
|
132
136
|
d_last = k[1].to_i if k[0] == i[0]
|
133
137
|
end
|
134
138
|
dd = GRuby::Analytics.generate_delta_explaination(d_this, d_last, refresh)
|
135
|
-
|
139
|
+
if d_last == 0
|
140
|
+
del = 0
|
141
|
+
else
|
142
|
+
del = ((d_this.to_i - d_last.to_i) * 100 / d_last.to_f)
|
143
|
+
end
|
136
144
|
response_obj << {tag: metrics.gsub("ga:", ""), val: i[1], dimension: i[0], delta: del, delta_explaination: dd}
|
137
145
|
end
|
138
146
|
elsif dimensions.split(",").count > 1 and metrics.split(",").count == 1
|
@@ -151,7 +159,11 @@ class GRuby::Analytics
|
|
151
159
|
d_last = k[2] if (k[0] == i[0] and k[1] == i[1])
|
152
160
|
end
|
153
161
|
dd = GRuby::Analytics.generate_delta_explaination(d_this, d_last, refresh)
|
154
|
-
|
162
|
+
if d_last.to_f == 0
|
163
|
+
del = 0
|
164
|
+
else
|
165
|
+
del = ((d_this.to_i - d_last.to_i) * 100 / d_last.to_f)
|
166
|
+
end
|
155
167
|
response_obj << {tag: i[0], val: i[2], dimension: k3, delta: del, delta_explaination: dd}
|
156
168
|
end
|
157
169
|
end
|