active_reporter 0.6.3 → 0.6.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (68) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +9 -9
  3. data/lib/active_reporter/aggregator/array.rb +1 -1
  4. data/lib/active_reporter/aggregator/count.rb +2 -2
  5. data/lib/active_reporter/aggregator/count_if.rb +2 -2
  6. data/lib/active_reporter/aggregator.rb +9 -9
  7. data/lib/active_reporter/calculator.rb +2 -2
  8. data/lib/active_reporter/dimension/base.rb +3 -3
  9. data/lib/active_reporter/dimension/bin/set.rb +3 -3
  10. data/lib/active_reporter/dimension/bin/table.rb +1 -1
  11. data/lib/active_reporter/dimension/bin.rb +23 -15
  12. data/lib/active_reporter/dimension/category.rb +1 -1
  13. data/lib/active_reporter/dimension/enum.rb +1 -1
  14. data/lib/active_reporter/dimension/number.rb +3 -3
  15. data/lib/active_reporter/dimension/time.rb +4 -4
  16. data/lib/active_reporter/dimension.rb +8 -8
  17. data/lib/active_reporter/evaluator.rb +2 -2
  18. data/lib/active_reporter/inflector.rb +1 -1
  19. data/lib/active_reporter/report/aggregation.rb +12 -12
  20. data/lib/active_reporter/report/definition.rb +6 -6
  21. data/lib/active_reporter/report/validation.rb +9 -9
  22. data/lib/active_reporter/report.rb +3 -3
  23. data/lib/active_reporter/serializer/base.rb +6 -6
  24. data/lib/active_reporter/serializer/csv.rb +2 -2
  25. data/lib/active_reporter/serializer/form_field.rb +5 -5
  26. data/lib/active_reporter/serializer/highcharts.rb +6 -6
  27. data/lib/active_reporter/serializer.rb +7 -7
  28. data/lib/active_reporter/tracker/base.rb +1 -1
  29. data/lib/active_reporter/tracker.rb +3 -3
  30. data/lib/active_reporter/version.rb +1 -1
  31. data/lib/active_reporter.rb +7 -3
  32. data/spec/acceptance/data_spec.rb +49 -49
  33. data/spec/active_reporter/aggregator_spec.rb +37 -37
  34. data/spec/active_reporter/dimension/base_spec.rb +29 -29
  35. data/spec/active_reporter/dimension/bin/set_spec.rb +29 -29
  36. data/spec/active_reporter/dimension/bin/table_spec.rb +7 -7
  37. data/spec/active_reporter/dimension/bin_spec.rb +12 -12
  38. data/spec/active_reporter/dimension/category_spec.rb +22 -22
  39. data/spec/active_reporter/dimension/enum_spec.rb +12 -12
  40. data/spec/active_reporter/dimension/number_spec.rb +11 -11
  41. data/spec/active_reporter/dimension/time_spec.rb +20 -20
  42. data/spec/active_reporter/report_spec.rb +162 -162
  43. data/spec/active_reporter/serializer/hash_table_spec.rb +13 -13
  44. data/spec/active_reporter/serializer/highcharts_spec.rb +30 -30
  45. data/spec/active_reporter/serializer/table_spec.rb +22 -22
  46. data/spec/dummy/Rakefile +1 -1
  47. data/spec/dummy/app/models/post_report.rb +1 -1
  48. data/spec/dummy/app/views/layouts/application.html.erb +2 -2
  49. data/spec/dummy/app/views/site/report.html.erb +5 -5
  50. data/spec/dummy/bin/bundle +2 -2
  51. data/spec/dummy/bin/rails +3 -3
  52. data/spec/dummy/bin/rake +2 -2
  53. data/spec/dummy/bin/setup +2 -2
  54. data/spec/dummy/config/application.rb +4 -4
  55. data/spec/dummy/config/boot.rb +3 -3
  56. data/spec/dummy/config/database.yml +3 -3
  57. data/spec/dummy/config/environment.rb +1 -1
  58. data/spec/dummy/config/environments/production.rb +4 -4
  59. data/spec/dummy/config/environments/test.rb +1 -1
  60. data/spec/dummy/config/initializers/assets.rb +1 -1
  61. data/spec/dummy/config/initializers/inflections.rb +4 -4
  62. data/spec/dummy/config/initializers/session_store.rb +1 -1
  63. data/spec/dummy/config/locales/en.yml +2 -2
  64. data/spec/dummy/config/routes.rb +9 -9
  65. data/spec/dummy/config.ru +1 -1
  66. data/spec/dummy/log/test.log +68265 -0
  67. data/spec/spec_helper.rb +13 -13
  68. metadata +50 -30
@@ -2,7 +2,7 @@ module ActiveReporter
2
2
  module Serializer
3
3
  class Highcharts < Table
4
4
  def colors
5
- ['#7cb5ec', '#434348', '#90ed7d', '#f7a35c', '#8085e9', '#f15c80', '#e4d354', '#2b908f', '#f45b5b', '#91e8e1']
5
+ ["#7cb5ec", "#434348", "#90ed7d", "#f7a35c", "#8085e9", "#f15c80", "#e4d354", "#2b908f", "#f45b5b", "#91e8e1"]
6
6
  end
7
7
 
8
8
  def color_hash
@@ -118,7 +118,7 @@ module ActiveReporter
118
118
  human_aggregator_label(report.all_aggregators),
119
119
  human_aggregator_value_label(report.all_aggregators, xes[report.groupers.first][:value])
120
120
  ]
121
- lines.map { |k, v| "<b>#{k}:</b> #{v}" }.join('<br/>')
121
+ lines.map { |k, v| "<b>#{k}:</b> #{v}" }.join("<br/>")
122
122
  end
123
123
 
124
124
  def filters_for(xes)
@@ -153,7 +153,7 @@ module ActiveReporter
153
153
  def highcharts_options
154
154
  {
155
155
  chart: {
156
- type: 'column'
156
+ type: "column"
157
157
  },
158
158
  colors: colors,
159
159
  title: {
@@ -176,9 +176,9 @@ module ActiveReporter
176
176
  },
177
177
  stackLabels: {
178
178
  enabled: report.groupers.length >= 3,
179
- format: '{stack}',
179
+ format: "{stack}",
180
180
  rotation: -45,
181
- textAlign: 'left'
181
+ textAlign: "left"
182
182
  }
183
183
  },
184
184
  legend: {
@@ -190,7 +190,7 @@ module ActiveReporter
190
190
  events: {}
191
191
  },
192
192
  column: {
193
- stacking: ('normal' if report.groupers.length >= 2)
193
+ stacking: ("normal" if report.groupers.length >= 2)
194
194
  }
195
195
  }
196
196
  }
@@ -1,7 +1,7 @@
1
- require 'active_reporter/serializer/base'
2
- require 'active_reporter/serializer/table'
3
- require 'active_reporter/serializer/csv'
4
- require 'active_reporter/serializer/form_field'
5
- require 'active_reporter/serializer/highcharts'
6
- require 'active_reporter/serializer/hash_table'
7
- require 'active_reporter/serializer/nested_hash'
1
+ require "active_reporter/serializer/base"
2
+ require "active_reporter/serializer/table"
3
+ require "active_reporter/serializer/csv"
4
+ require "active_reporter/serializer/form_field"
5
+ require "active_reporter/serializer/highcharts"
6
+ require "active_reporter/serializer/hash_table"
7
+ require "active_reporter/serializer/nested_hash"
@@ -1,4 +1,4 @@
1
- require 'active_reporter/aggregator/base'
1
+ require "active_reporter/aggregator/base"
2
2
 
3
3
  module ActiveReporter
4
4
  module Tracker
@@ -1,3 +1,3 @@
1
- require 'active_reporter/tracker/base'
2
- require 'active_reporter/tracker/delta'
3
- require 'active_reporter/tracker/value'
1
+ require "active_reporter/tracker/base"
2
+ require "active_reporter/tracker/delta"
3
+ require "active_reporter/tracker/value"
@@ -1,3 +1,3 @@
1
1
  module ActiveReporter
2
- VERSION = "0.6.3"
2
+ VERSION = "0.6.4"
3
3
  end
@@ -17,10 +17,14 @@ module ActiveReporter
17
17
  private
18
18
 
19
19
  def database_adapter
20
- ActiveRecord::Base.connection_config[:adapter]
20
+ @database_adapter ||= if ActiveRecord.gem_version < Gem::Version.new("6")
21
+ ActiveRecord::Base.connection_config[:adapter]
22
+ else
23
+ ActiveRecord::Base.connection_db_config.adapter
24
+ end
21
25
  end
22
26
  end
23
27
  end
24
28
 
25
- require 'deeply_enumerable'
26
- Dir.glob(File.join(__dir__, 'active_reporter', '*/')).each { |file| require file.chomp('/') }
29
+ require "deeply_enumerable"
30
+ Dir.glob(File.join(__dir__, "active_reporter", "*/")).each { |file| require file.chomp("/") }
@@ -1,6 +1,6 @@
1
- require 'spec_helper'
1
+ require "spec_helper"
2
2
 
3
- describe 'more complicated case' do
3
+ describe "more complicated case" do
4
4
  let(:report_model) do
5
5
  Class.new(ActiveReporter::Report) do
6
6
  report_on :Post
@@ -61,12 +61,12 @@ describe 'more complicated case' do
61
61
  expect(h1_json).to eq h2_json
62
62
  end
63
63
 
64
- let(:joyce) { create(:author, name: 'James Joyce') }
65
- let(:woolf) { create(:author, name: 'Virginia Woolf') }
64
+ let(:joyce) { create(:author, name: "James Joyce") }
65
+ let(:woolf) { create(:author, name: "Virginia Woolf") }
66
66
 
67
- let(:oct_1) { Time.zone.parse('2015-10-01') }
68
- let(:nov_1) { Time.zone.parse('2015-11-01') }
69
- let(:dec_1) { Time.zone.parse('2015-12-01') }
67
+ let(:oct_1) { Time.zone.parse("2015-10-01") }
68
+ let(:nov_1) { Time.zone.parse("2015-11-01") }
69
+ let(:dec_1) { Time.zone.parse("2015-12-01") }
70
70
 
71
71
  let(:oct) { { min: oct_1, max: nov_1 } }
72
72
  let(:nov) { { min: nov_1, max: dec_1 } }
@@ -83,50 +83,50 @@ describe 'more complicated case' do
83
83
  let!(:post_8) { create(:post, author: nil, published_at: oct_1, likes: 2) }
84
84
  let!(:post_9) { create(:post, author: nil, published_at: nov_1, likes: 3) }
85
85
 
86
- specify 'basic grouping, 1 grouper, no filters' do
86
+ specify "basic grouping, 1 grouper, no filters" do
87
87
  expect_equal data_by(:author), [
88
88
  { key: nil, values: [
89
89
  { key: :count, value: 2 },
90
90
  { key: :total_likes, value: 5 },
91
- { key: :mean_likes, value: '2.5' },
91
+ { key: :mean_likes, value: "2.5" },
92
92
  { key: :min_likes, value: 2 },
93
93
  { key: :max_likes, value: 3 }
94
94
  ] },
95
95
  { key: joyce.name, values: [
96
96
  { key: :count, value: 4 },
97
97
  { key: :total_likes, value: 7 },
98
- { key: :mean_likes, value: '1.75' },
98
+ { key: :mean_likes, value: "1.75" },
99
99
  { key: :min_likes, value: 1 },
100
100
  { key: :max_likes, value: 3 }
101
101
  ] },
102
102
  { key: woolf.name, values: [
103
103
  { key: :count, value: 3 },
104
104
  { key: :total_likes, value: 8 },
105
- { key: :mean_likes, value: '2.6666666666666667' },
105
+ { key: :mean_likes, value: "2.6666666666666667" },
106
106
  { key: :min_likes, value: 2 },
107
107
  { key: :max_likes, value: 3 }
108
108
  ] }
109
109
  ]
110
110
 
111
- expect_equal data_by(:published_at, bin_width: '1 month'), [
111
+ expect_equal data_by(:published_at, bin_width: "1 month"), [
112
112
  { key: nil, values: [
113
113
  { key: :count, value: 2 },
114
114
  { key: :total_likes, value: 6 },
115
- { key: :mean_likes, value: '3.0' },
115
+ { key: :mean_likes, value: "3.0" },
116
116
  { key: :min_likes, value: 3 },
117
117
  { key: :max_likes, value: 3 }
118
118
  ] },
119
119
  { key: oct, values: [
120
120
  { key: :count, value: 4 },
121
121
  { key: :total_likes, value: 7 },
122
- { key: :mean_likes, value: '1.75' },
122
+ { key: :mean_likes, value: "1.75" },
123
123
  { key: :min_likes, value: 1 },
124
124
  { key: :max_likes, value: 2 }
125
125
  ] },
126
126
  { key: nov, values: [
127
127
  { key: :count, value: 3 },
128
128
  { key: :total_likes, value: 7 },
129
- { key: :mean_likes, value: '2.3333333333333333' },
129
+ { key: :mean_likes, value: "2.3333333333333333" },
130
130
  { key: :min_likes, value: 1 },
131
131
  { key: :max_likes, value: 3 }
132
132
  ] }
@@ -136,28 +136,28 @@ describe 'more complicated case' do
136
136
  { key: { min: 1, max: 2 }, values: [
137
137
  { key: :count, value: 2 },
138
138
  { key: :total_likes, value: 2 },
139
- { key: :mean_likes, value: '1.0' },
139
+ { key: :mean_likes, value: "1.0" },
140
140
  { key: :min_likes, value: 1 },
141
141
  { key: :max_likes, value: 1 }
142
142
  ] },
143
143
  { key: { min: 2, max: 3 }, values: [
144
144
  { key: :count, value: 3 },
145
145
  { key: :total_likes, value: 6 },
146
- { key: :mean_likes, value: '2.0' },
146
+ { key: :mean_likes, value: "2.0" },
147
147
  { key: :min_likes, value: 2 },
148
148
  { key: :max_likes, value: 2 }
149
149
  ] },
150
150
  { key: { min: 3, max: 4 }, values: [
151
151
  { key: :count, value: 4 },
152
152
  { key: :total_likes, value: 12 },
153
- { key: :mean_likes, value: '3.0' },
153
+ { key: :mean_likes, value: "3.0" },
154
154
  { key: :min_likes, value: 3 },
155
155
  { key: :max_likes, value: 3 }
156
156
  ] }
157
157
  ]
158
158
  end
159
159
 
160
- specify 'basic grouping, >=2 groupers, no filters' do
160
+ specify "basic grouping, >=2 groupers, no filters" do
161
161
  expect_equal data_by([:published_at, :author], bin_width: { months: 1 }), [
162
162
  { key: nil, values: [
163
163
  { key: nil, values: [
@@ -170,14 +170,14 @@ describe 'more complicated case' do
170
170
  { key: oct, values: [
171
171
  { key: :count, value: 1 },
172
172
  { key: :total_likes, value: 2 },
173
- { key: :mean_likes, value: '2.0' },
173
+ { key: :mean_likes, value: "2.0" },
174
174
  { key: :min_likes, value: 2 },
175
175
  { key: :max_likes, value: 2 }
176
176
  ] },
177
177
  { key: nov, values: [
178
178
  { key: :count, value: 1 },
179
179
  { key: :total_likes, value: 3 },
180
- { key: :mean_likes, value: '3.0' },
180
+ { key: :mean_likes, value: "3.0" },
181
181
  { key: :min_likes, value: 3 },
182
182
  { key: :max_likes, value: 3 }
183
183
  ] }
@@ -186,21 +186,21 @@ describe 'more complicated case' do
186
186
  { key: nil, values: [
187
187
  { key: :count, value: 1 },
188
188
  { key: :total_likes, value: 3 },
189
- { key: :mean_likes, value: '3.0' },
189
+ { key: :mean_likes, value: "3.0" },
190
190
  { key: :min_likes, value: 3 },
191
191
  { key: :max_likes, value: 3 }
192
192
  ] },
193
193
  { key: oct, values: [
194
194
  { key: :count, value: 2 },
195
195
  { key: :total_likes, value: 3 },
196
- { key: :mean_likes, value: '1.5' },
196
+ { key: :mean_likes, value: "1.5" },
197
197
  { key: :min_likes, value: 1 },
198
198
  { key: :max_likes, value: 2 }
199
199
  ] },
200
200
  { key: nov, values: [
201
201
  { key: :count, value: 1 },
202
202
  { key: :total_likes, value: 1 },
203
- { key: :mean_likes, value: '1.0' },
203
+ { key: :mean_likes, value: "1.0" },
204
204
  { key: :min_likes, value: 1 },
205
205
  { key: :max_likes, value: 1 }
206
206
  ] }
@@ -209,21 +209,21 @@ describe 'more complicated case' do
209
209
  { key: nil, values: [
210
210
  { key: :count, value: 1 },
211
211
  { key: :total_likes, value: 3 },
212
- { key: :mean_likes, value: '3.0' },
212
+ { key: :mean_likes, value: "3.0" },
213
213
  { key: :min_likes, value: 3 },
214
214
  { key: :max_likes, value: 3 }
215
215
  ] },
216
216
  { key: oct, values: [
217
217
  { key: :count, value: 1 },
218
218
  { key: :total_likes, value: 2 },
219
- { key: :mean_likes, value: '2.0' },
219
+ { key: :mean_likes, value: "2.0" },
220
220
  { key: :min_likes, value: 2 },
221
221
  { key: :max_likes, value: 2 }
222
222
  ] },
223
223
  { key: nov, values: [
224
224
  { key: :count, value: 1 },
225
225
  { key: :total_likes, value: 3 },
226
- { key: :mean_likes, value: '3.0' },
226
+ { key: :mean_likes, value: "3.0" },
227
227
  { key: :min_likes, value: 3 },
228
228
  { key: :max_likes, value: 3 }
229
229
  ] }
@@ -231,50 +231,50 @@ describe 'more complicated case' do
231
231
  ]
232
232
  end
233
233
 
234
- specify 'sorting with nulls (1 grouper)' do
234
+ specify "sorting with nulls (1 grouper)" do
235
235
  expect_equal data_by(:author, sort_desc: true), [
236
236
  { key: woolf.name, values: [
237
237
  { key: :count, value: 3 },
238
238
  { key: :total_likes, value: 8 },
239
- { key: :mean_likes, value: '2.6666666666666667' },
239
+ { key: :mean_likes, value: "2.6666666666666667" },
240
240
  { key: :min_likes, value: 2 },
241
241
  { key: :max_likes, value: 3 }
242
242
  ] },
243
243
  { key: joyce.name, values: [
244
244
  { key: :count, value: 4 },
245
245
  { key: :total_likes, value: 7 },
246
- { key: :mean_likes, value: '1.75' },
246
+ { key: :mean_likes, value: "1.75" },
247
247
  { key: :min_likes, value: 1 },
248
248
  { key: :max_likes, value: 3 }
249
249
  ] },
250
250
  { key: nil, values: [
251
251
  {key: :count, value: 2 },
252
252
  {key: :total_likes, value: 5 },
253
- {key: :mean_likes, value: '2.5' },
253
+ {key: :mean_likes, value: "2.5" },
254
254
  {key: :min_likes, value: 2 },
255
255
  {key: :max_likes, value: 3 }
256
256
  ] }
257
257
  ]
258
258
 
259
- expect_equal data_by(:published_at, bin_width: '1 month', sort_desc: true), [
259
+ expect_equal data_by(:published_at, bin_width: "1 month", sort_desc: true), [
260
260
  { key: nov, values: [
261
261
  { key: :count, value: 3 },
262
262
  { key: :total_likes, value: 7 },
263
- { key: :mean_likes, value: '2.3333333333333333' },
263
+ { key: :mean_likes, value: "2.3333333333333333" },
264
264
  { key: :min_likes, value: 1 },
265
265
  { key: :max_likes, value: 3 }
266
266
  ] },
267
267
  { key: oct, values: [
268
268
  { key: :count, value: 4 },
269
269
  { key: :total_likes, value: 7 },
270
- { key: :mean_likes, value: '1.75' },
270
+ { key: :mean_likes, value: "1.75" },
271
271
  { key: :min_likes, value: 1 },
272
272
  { key: :max_likes, value: 2 }
273
273
  ] },
274
274
  { key: nil, values: [
275
275
  { key: :count, value: 2 },
276
276
  { key: :total_likes, value: 6 },
277
- { key: :mean_likes, value: '3.0' },
277
+ { key: :mean_likes, value: "3.0" },
278
278
  { key: :min_likes, value: 3 },
279
279
  { key: :max_likes, value: 3 }
280
280
  ] }
@@ -285,21 +285,21 @@ describe 'more complicated case' do
285
285
  { key: joyce.name, values: [
286
286
  { key: :count, value: 4 },
287
287
  { key: :total_likes, value: 7 },
288
- { key: :mean_likes, value: '1.75' },
288
+ { key: :mean_likes, value: "1.75" },
289
289
  { key: :min_likes, value: 1 },
290
290
  { key: :max_likes, value: 3 }
291
291
  ] },
292
292
  { key: woolf.name, values: [
293
293
  { key: :count, value: 3 },
294
294
  { key: :total_likes, value: 8 },
295
- { key: :mean_likes, value: '2.6666666666666667' },
295
+ { key: :mean_likes, value: "2.6666666666666667" },
296
296
  { key: :min_likes, value: 2 },
297
297
  { key: :max_likes, value: 3 }
298
298
  ] },
299
299
  { key: nil, values: [
300
300
  { key: :count, value: 2 },
301
301
  { key: :total_likes, value: 5 },
302
- { key: :mean_likes, value: '2.5' },
302
+ { key: :mean_likes, value: "2.5" },
303
303
  { key: :min_likes, value: 2 },
304
304
  { key: :max_likes, value: 3 }
305
305
  ] }
@@ -309,69 +309,69 @@ describe 'more complicated case' do
309
309
  { key: nil, values: [
310
310
  { key: :count, value: 2 },
311
311
  { key: :total_likes, value: 5 },
312
- { key: :mean_likes, value: '2.5' },
312
+ { key: :mean_likes, value: "2.5" },
313
313
  { key: :min_likes, value: 2 },
314
314
  { key: :max_likes, value: 3 }
315
315
  ] },
316
316
  { key: woolf.name, values: [
317
317
  { key: :count, value: 3 },
318
318
  { key: :total_likes, value: 8 },
319
- { key: :mean_likes, value: '2.6666666666666667' },
319
+ { key: :mean_likes, value: "2.6666666666666667" },
320
320
  { key: :min_likes, value: 2 },
321
321
  { key: :max_likes, value: 3 }
322
322
  ] },
323
323
  { key: joyce.name, values: [
324
324
  { key: :count, value: 4 },
325
325
  { key: :total_likes, value: 7 },
326
- { key: :mean_likes, value: '1.75' },
326
+ { key: :mean_likes, value: "1.75" },
327
327
  { key: :min_likes, value: 1 },
328
328
  { key: :max_likes, value: 3 }
329
329
  ] }
330
330
  ]
331
331
 
332
- expect_equal data_by(:published_at, bin_width: '1 month', nulls_last: true), [
332
+ expect_equal data_by(:published_at, bin_width: "1 month", nulls_last: true), [
333
333
  { key: oct, values: [
334
334
  { key: :count, value: 4 },
335
335
  { key: :total_likes, value: 7 },
336
- { key: :mean_likes, value: '1.75' },
336
+ { key: :mean_likes, value: "1.75" },
337
337
  { key: :min_likes, value: 1 },
338
338
  { key: :max_likes, value: 2 }
339
339
  ] },
340
340
  { key: nov, values: [
341
341
  { key: :count, value: 3 },
342
342
  { key: :total_likes, value: 7 },
343
- { key: :mean_likes, value: '2.3333333333333333' },
343
+ { key: :mean_likes, value: "2.3333333333333333" },
344
344
  { key: :min_likes, value: 1 },
345
345
  { key: :max_likes, value: 3 }
346
346
  ] },
347
347
  { key: nil, values: [
348
348
  { key: :count, value: 2 },
349
349
  { key: :total_likes, value: 6 },
350
- { key: :mean_likes, value: '3.0' },
350
+ { key: :mean_likes, value: "3.0" },
351
351
  { key: :min_likes, value: 3 },
352
352
  { key: :max_likes, value: 3 }
353
353
  ] }
354
354
  ]
355
355
 
356
- expect_equal data_by(:published_at, bin_width: '1 month', sort_desc: true, nulls_last: true), [
356
+ expect_equal data_by(:published_at, bin_width: "1 month", sort_desc: true, nulls_last: true), [
357
357
  { key: nil, values: [
358
358
  { key: :count, value: 2 },
359
359
  { key: :total_likes, value: 6 },
360
- { key: :mean_likes, value: '3.0' },
360
+ { key: :mean_likes, value: "3.0" },
361
361
  { key: :min_likes, value: 3 },
362
362
  { key: :max_likes, value: 3 }
363
363
  ] },
364
364
  { key: nov, values: [
365
365
  { key: :count, value: 3 },
366
366
  { key: :total_likes, value: 7 },
367
- { key: :mean_likes, value: '2.3333333333333333' },
367
+ { key: :mean_likes, value: "2.3333333333333333" },
368
368
  { key: :min_likes, value: 1 },
369
369
  { key: :max_likes, value: 3 }
370
370
  ] },
371
371
  { key: oct, values: [
372
372
  { key: :count, value: 4 },
373
373
  { key: :total_likes, value: 7 },
374
- { key: :mean_likes, value: '1.75' },
374
+ { key: :mean_likes, value: "1.75" },
375
375
  { key: :min_likes, value: 1 },
376
376
  { key: :max_likes, value: 2 }
377
377
  ] }
@@ -1,4 +1,4 @@
1
- require 'spec_helper'
1
+ require "spec_helper"
2
2
 
3
3
  describe ActiveReporter::Aggregator do
4
4
  let(:report_model) do
@@ -17,22 +17,22 @@ describe ActiveReporter::Aggregator do
17
17
 
18
18
  let(:report) { report_model.new(aggregators: aggregators, groupers: [:author, :status]) }
19
19
 
20
- let!(:post_1) { create(:post, likes: 3, author: 'Alice') }
21
- let!(:post_2) { create(:post, likes: 2, author: 'Alice') }
22
- let!(:post_3) { create(:post, likes: 4, author: 'Bob') }
23
- let!(:post_4) { create(:post, likes: 1, author: 'Bob') }
24
- let!(:post_5) { create(:post, likes: 5, author: 'Bob') }
25
- let!(:post_6) { create(:post, likes: 10, author: 'Chester') }
20
+ let!(:post_1) { create(:post, likes: 3, author: "Alice") }
21
+ let!(:post_2) { create(:post, likes: 2, author: "Alice") }
22
+ let!(:post_3) { create(:post, likes: 4, author: "Bob") }
23
+ let!(:post_4) { create(:post, likes: 1, author: "Bob") }
24
+ let!(:post_5) { create(:post, likes: 5, author: "Bob") }
25
+ let!(:post_6) { create(:post, likes: 10, author: "Chester") }
26
26
 
27
- context 'aggregating post_ids' do
27
+ context "aggregating post_ids" do
28
28
  let(:aggregators) { :post_ids }
29
29
 
30
- it 'should return post_ids values' do
30
+ it "should return post_ids values" do
31
31
  if ActiveReporter.database_type == :postgres
32
32
  expect(report.raw_data).to eq({
33
- ['Alice', 'published', 'post_ids'] => [post_1.id, post_2.id],
34
- ['Bob', 'published', 'post_ids'] => [post_3.id, post_4.id, post_5.id],
35
- ['Chester', 'published', 'post_ids'] => [post_6.id],
33
+ ["Alice", "published", "post_ids"] => [post_1.id, post_2.id],
34
+ ["Bob", "published", "post_ids"] => [post_3.id, post_4.id, post_5.id],
35
+ ["Chester", "published", "post_ids"] => [post_6.id],
36
36
  })
37
37
  else
38
38
  expect { report.raw_data }.to raise_error(ActiveReporter::InvalidParamsError)
@@ -40,62 +40,62 @@ describe ActiveReporter::Aggregator do
40
40
  end
41
41
  end
42
42
 
43
- context 'aggregating max_likes' do
43
+ context "aggregating max_likes" do
44
44
  let(:aggregators) { :max_likes }
45
45
 
46
- it 'should return max_likes values' do
46
+ it "should return max_likes values" do
47
47
  expect(report.raw_data).to eq({
48
- ['Alice', 'published', 'max_likes'] => 3,
49
- ['Bob', 'published', 'max_likes'] => 5,
50
- ['Chester', 'published', 'max_likes'] => 10,
48
+ ["Alice", "published", "max_likes"] => 3,
49
+ ["Bob", "published", "max_likes"] => 5,
50
+ ["Chester", "published", "max_likes"] => 10,
51
51
  })
52
52
  end
53
53
  end
54
54
 
55
- context 'aggregating min_likes' do
55
+ context "aggregating min_likes" do
56
56
  let(:aggregators) { :min_likes }
57
57
 
58
- it 'should return min_likes values' do
58
+ it "should return min_likes values" do
59
59
  expect(report.raw_data).to eq({
60
- ['Alice', 'published', 'min_likes'] => 2,
61
- ['Bob', 'published', 'min_likes'] => 1,
62
- ['Chester', 'published', 'min_likes'] => 10
60
+ ["Alice", "published", "min_likes"] => 2,
61
+ ["Bob", "published", "min_likes"] => 1,
62
+ ["Chester", "published", "min_likes"] => 10
63
63
  })
64
64
  end
65
65
  end
66
66
 
67
- context 'aggregating mean_likes' do
67
+ context "aggregating mean_likes" do
68
68
  let(:aggregators) { :mean_likes }
69
69
 
70
- it 'should return mean_likes values' do
70
+ it "should return mean_likes values" do
71
71
  expect(report.raw_data.collect{ |k,v| [k, v.round(2)] }.to_h).to eq({
72
- ['Alice', 'published', 'mean_likes'] => 2.50,
73
- ['Bob', 'published', 'mean_likes'] => 3.33,
74
- ['Chester', 'published', 'mean_likes'] => 10.00,
72
+ ["Alice", "published", "mean_likes"] => 2.50,
73
+ ["Bob", "published", "mean_likes"] => 3.33,
74
+ ["Chester", "published", "mean_likes"] => 10.00,
75
75
  })
76
76
  end
77
77
  end
78
78
 
79
- context 'aggregating total_likes' do
79
+ context "aggregating total_likes" do
80
80
  let(:aggregators) { :total_likes }
81
81
 
82
- it 'should return total_likes values' do
82
+ it "should return total_likes values" do
83
83
  expect(report.raw_data).to eq({
84
- ['Alice', 'published', 'total_likes'] => 5,
85
- ['Bob', 'published', 'total_likes'] => 10,
86
- ['Chester', 'published', 'total_likes'] => 10
84
+ ["Alice", "published", "total_likes"] => 5,
85
+ ["Bob", "published", "total_likes"] => 10,
86
+ ["Chester", "published", "total_likes"] => 10
87
87
  })
88
88
  end
89
89
  end
90
90
 
91
- context 'aggregating count' do
91
+ context "aggregating count" do
92
92
  let(:aggregators) { :count }
93
93
 
94
- it 'should return count values' do
94
+ it "should return count values" do
95
95
  expect(report.raw_data).to eq({
96
- ['Alice', 'published', 'count'] => 2,
97
- ['Bob', 'published', 'count'] => 3,
98
- ['Chester', 'published', 'count'] => 1
96
+ ["Alice", "published", "count"] => 2,
97
+ ["Bob", "published", "count"] => 3,
98
+ ["Chester", "published", "count"] => 1
99
99
  })
100
100
  end
101
101
  end