active_reporting 0.1.1 → 0.2.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c3ef7db85c82db17046183576d9a62cfe08acbcc
4
- data.tar.gz: ed929413c1768196e855b3116bc76c82df631cc8
3
+ metadata.gz: a42a126d95b11825c31edc43efd23fb483238266
4
+ data.tar.gz: 1679cf35f25aeee3f40117ffce4d4b4fdf8be499
5
5
  SHA512:
6
- metadata.gz: f74516592d42a6494db7f827a1bcbf7391c9d4a5ff44e181205b6bf385a692fa57e62fdfec7005007e606dfb8a65e13f073618670eb3a76f10a6ef64272ceaaf
7
- data.tar.gz: 2ff7e312d8f749199fa022e2000e825bfbd6c58174e81be4ef4a7b2dd09c7301cf898f7bb34ef70682fdd1907928333decdee867a358239cd1e401deea084cc2
6
+ metadata.gz: 2eb0fba1d05b5f482716db8cd47cf165546c35533e061a46d55abc8708359b3ba3f0812db60d68b85cf1375554f25037a6e83ff231db1e988d4b6014e2198431
7
+ data.tar.gz: d2d2be2376f03a9590142bd732369426510c7f0916bc432f42e82c14e4dcff406a726a8de53ae2a4d7774b8f39e93c3485c54236eafd244dcf8a022a3494f609
data/.travis.yml CHANGED
@@ -5,20 +5,15 @@ rvm:
5
5
  - 2.3.4
6
6
  - 2.4.1
7
7
  env:
8
+ - RAILS=5-1 DB=sqlite
9
+ - RAILS=5-1 DB=pg
10
+ - RAILS=5-1 DB=mysql
8
11
  - RAILS=5-0 DB=sqlite
9
12
  - RAILS=5-0 DB=pg
10
13
  - RAILS=5-0 DB=mysql
11
14
  - RAILS=4-2 DB=sqlite
12
15
  - RAILS=4-2 DB=pg
13
16
  - RAILS=4-2 DB=mysql
14
- matrix:
15
- exclude:
16
- - rvm: 2.2.7
17
- env: RAILS=5-0 DB=sqlite
18
- - rvm: 2.2.7
19
- env: RAILS=5-0 DB=pg
20
- - rvm: 2.2.7
21
- env: RAILS=5-0 DB=mysql
22
17
  before_script:
23
18
  - psql -c 'create database active_reporting_test;' -U postgres
24
19
  - mysql -e 'create database active_reporting_test collate utf8_general_ci;'
data/CHANGELOG.md CHANGED
@@ -1,6 +1,25 @@
1
+ ## 0.2.0 (2017-06-17)
2
+
3
+ ### Breaking Changes
4
+
5
+ * `FactModel.use_model` renamed to `FactModel.model=`
6
+
7
+ ### Bug Fixes
8
+
9
+ * `metric` lives on fact model and not metric (#3) - *Michael Wheeler (wheeyls)*
10
+
11
+ ### Misc
12
+
13
+ * Readme corrections and updates (#2) - *Michael Wheeler (wheeyls)*
14
+
1
15
  ## 0.1.1 (2017-04-22)
2
16
 
17
+ ### Bug Fixes
18
+
3
19
  * Fix MySQL querying
20
+
21
+ ### Misc
22
+
4
23
  * Properly test against multiple dbs and versions of ActiveRecord in CI
5
24
 
6
25
  ## 0.1.0 (2017-04-16)
data/Gemfile CHANGED
@@ -4,11 +4,13 @@ gemspec
4
4
 
5
5
  gem 'simplecov', require: false
6
6
 
7
- rails = ENV['RAILS'] || '5-0'
7
+ rails = ENV['RAILS'] || '5-1'
8
8
 
9
9
  case rails
10
10
  when '4-2'
11
11
  gem 'activerecord', '~> 4.2.0'
12
- else
12
+ when '5-0'
13
13
  gem 'activerecord', '~> 5.0.0'
14
+ else
15
+ gem 'activerecord', '~> 5.1.0'
14
16
  end
data/README.md CHANGED
@@ -37,6 +37,7 @@ ROLAP uses a set of terms to describe how a report is generated. ActiveReporting
37
37
  A fact table is the primary table where information is derived from in a report. It commonly contains fact columns (usually numeric values) and dimension columns (foreign keys to other tables or values that can be grouped together).
38
38
 
39
39
  SQL Equivalent: FROM
40
+
40
41
  Rails: ActiveRecord model
41
42
 
42
43
  ### Dimension
@@ -49,6 +50,7 @@ Examples:
49
50
  * The manufacture on a fact table of widgets
50
51
 
51
52
  SQL Equivalent: JOIN, GROUP BY
53
+
52
54
  Rails: ActiveRecord relation or attribute
53
55
 
54
56
  ### Dimension Hierarchy
@@ -71,6 +73,7 @@ Examples:
71
73
  This isn't really an official term, but I like using it to describe further filtering of dimensionable data.
72
74
 
73
75
  SQL Equivalent: WHERE
76
+
74
77
  Rails: `where()`, scopes, etc.
75
78
 
76
79
  ### Measure
@@ -82,6 +85,7 @@ Examples:
82
85
  * Number of units used in a transaction
83
86
 
84
87
  SQL Equivalent: Column in the fact table used in an aggregation function
88
+
85
89
  Rails: ActiveRecord attribute
86
90
 
87
91
  ### Metric
@@ -89,6 +93,7 @@ Rails: ActiveRecord attribute
89
93
  A metric is a measured value and the subject of the report. It is the result of *the* question you want answered.
90
94
 
91
95
  SQL Equivalent: A query result
96
+
92
97
  Rails: The result of an ActiveRecord query
93
98
 
94
99
  ### Star Schema
@@ -147,20 +152,20 @@ Every fact model links to an ActiveRecord model. This is done either by naming c
147
152
  This naming convention is `[ModelName]FactModel`. Meaning if you have an ActiveRecord model named `Ticket`, you'll then have a `TicketFactModel` to link them together.
148
153
 
149
154
  ```ruby
150
- class TicketFactModel < ActiveRecord::FactModel
155
+ class TicketFactModel < ActiveReporting::FactModel
151
156
 
152
157
  end
153
158
  ```
154
159
 
155
- Alternatively, you may manually specify the model manually with `use_model`
160
+ Alternatively, you may manually specify the model manually with `self.model=`
156
161
 
157
162
  ```ruby
158
- class TicketFactModel < ActiveRecord::FactModel
159
- use_model SomeOtherModel
163
+ class TicketFactModel < ActiveReporting::FactModel
164
+ self.model= SomeOtherModel
160
165
  # OR you may pass in a string or symbol
161
- # use_model :some_other_model
162
- # use_model 'some_other_model'
163
- # use_model 'SomeOtherModel'
166
+ # self.model= :some_other_model
167
+ # self.model= 'some_other_model'
168
+ # self.model= 'SomeOtherModel'
164
169
  end
165
170
  ```
166
171
 
@@ -170,7 +175,7 @@ ActiveReporting assumes the column of a fact model used for summing, averaging,
170
175
 
171
176
  ```ruby
172
177
  class OrderFactModel < ActiveReporting::FactModel
173
- measure = :total
178
+ self.measure = :total
174
179
  end
175
180
  ```
176
181
 
@@ -258,7 +263,7 @@ my_metric = ActiveReporting::Metric.new(
258
263
 
259
264
  `aggregate` - The SQL aggregate used to calculate the metric. Supported aggregates include count, max, min, avg, and sum. (Default: `:count`)
260
265
 
261
- `dimensions - An array of dimensions used for the metric. When given just a symbol, the default dimension label will be used for the dimension. You may specify a hierarchy level by using a hash. (Examples: `[:sales_rep, {order_date: :month}]`)
266
+ `dimensions` - An array of dimensions used for the metric. When given just a symbol, the default dimension label will be used for the dimension. You may specify a hierarchy level by using a hash. (Examples: `[:sales_rep, {order_date: :month}]`)
262
267
 
263
268
  `dimension_filter` - A hash were the keys are dimension filter names and the values are the values passed into the filter.
264
269
 
@@ -278,7 +283,7 @@ metric = ActiveReporting::Metric.new(
278
283
  dimension_filter: {months_ago: 1}
279
284
  )
280
285
 
281
- report = ActiveReporting.new(metric)
286
+ report = ActiveReporting::Report.new(metric)
282
287
  report.run
283
288
  => [{order_count: 12, sales_rep: 'Fred Jones', sales_rep_identifier: 123},{order_count: 17, sales_rep: 'Mary Sue', sales_rep_identifier: 123}]
284
289
  ```
@@ -13,7 +13,7 @@ module ActiveReporting
13
13
  const_name.constantize
14
14
  rescue NameError
15
15
  const = Object.const_set(const_name, Class.new(ActiveReporting::FactModel))
16
- const.use_model self
16
+ const.model= self
17
17
  const
18
18
  end
19
19
  end
@@ -15,11 +15,11 @@ module ActiveReporting
15
15
  #
16
16
  # @example
17
17
  # class PostFactModel < ActiveReporting::FactModel
18
- # use_model :post
19
- # use_model Post
20
- # use_model 'post'
18
+ # self.model= :post
19
+ # self.model= Post
20
+ # self.model= 'post'
21
21
  # end
22
- def self.use_model(model)
22
+ def self.model=(model)
23
23
  @model = if model.is_a?(String) || model.is_a?(Symbol)
24
24
  model.to_s.classify.constantize
25
25
  else
@@ -78,7 +78,7 @@ module ActiveReporting
78
78
  when :count
79
79
  'COUNT(*)'
80
80
  else
81
- "#{@metric.aggregate.to_s.upcase}(#{@metric.measure})"
81
+ "#{@metric.aggregate.to_s.upcase}(#{fact_model.measure})"
82
82
  end
83
83
  end
84
84
 
@@ -1,3 +1,3 @@
1
1
  module ActiveReporting
2
- VERSION = '0.1.1'.freeze
2
+ VERSION = '0.2.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_reporting
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tony Drake
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-04-23 00:00:00.000000000 Z
11
+ date: 2017-06-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord