active_reporting 0.4.2 → 0.5.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 +4 -4
- data/.travis.yml +3 -17
- data/CHANGELOG.md +10 -0
- data/Gemfile +0 -16
- data/README.md +15 -15
- data/active_reporting.gemspec +1 -1
- data/lib/active_reporting/reporting_dimension.rb +4 -4
- data/lib/active_reporting/version.rb +1 -1
- metadata +11 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1bbb1cca5da777e98db50e52e0dd97a44e20cd9844c8d4d88cbb739485a7f22f
|
4
|
+
data.tar.gz: f3d5fcc3f6e174e6eb6ca582c57add3b844cc0deb632e6f844ee9990db31c93f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b57b0e82ebb5d1d645383d3aa88551b43c999c1443d0ecac6544d83295d6d1745f2956696499a5ce3ff249f8d91251e298a77e3921a68722d6842ffb7e90e705
|
7
|
+
data.tar.gz: 3fcec68b2de1a822ecef745f7b75ca6aaa7ae9587d7a25ce5ae5234a26e1d083bab01da4ccd70bafd47a9382810fb0932cb287ca7b18d20916789f4e0809b045
|
data/.travis.yml
CHANGED
@@ -5,9 +5,9 @@ services:
|
|
5
5
|
addons:
|
6
6
|
postgresql: "9.6"
|
7
7
|
rvm:
|
8
|
-
- 2.
|
9
|
-
- 2.
|
10
|
-
- 2.
|
8
|
+
- 2.5.8
|
9
|
+
- 2.6.6
|
10
|
+
- 2.7.1
|
11
11
|
env:
|
12
12
|
- RAILS=6-0 DB=sqlite
|
13
13
|
- RAILS=6-0 DB=pg
|
@@ -15,20 +15,6 @@ env:
|
|
15
15
|
- RAILS=5-2 DB=sqlite
|
16
16
|
- RAILS=5-2 DB=pg
|
17
17
|
- RAILS=5-2 DB=mysql
|
18
|
-
- RAILS=5-1 DB=sqlite
|
19
|
-
- RAILS=5-1 DB=pg
|
20
|
-
- RAILS=5-1 DB=mysql
|
21
|
-
- RAILS=4-2 DB=sqlite
|
22
|
-
- RAILS=4-2 DB=pg
|
23
|
-
- RAILS=4-2 DB=mysql
|
24
|
-
matrix:
|
25
|
-
exclude:
|
26
|
-
- rvm: 2.4.6
|
27
|
-
env: RAILS=6-0 DB=mysql
|
28
|
-
- rvm: 2.4.6
|
29
|
-
env: RAILS=6-0 DB=pg
|
30
|
-
- rvm: 2.4.6
|
31
|
-
env: RAILS=6-0 DB=sqlite
|
32
18
|
before_script:
|
33
19
|
- psql -c 'create database active_reporting_test;' -U postgres
|
34
20
|
- mysql -e 'create database active_reporting_test collate utf8_general_ci;'
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,13 @@
|
|
1
|
+
## 0.5.0 (2020-06-30)
|
2
|
+
|
3
|
+
### Bug Fixes
|
4
|
+
|
5
|
+
* Fix Missing quotation marks in column names causing SLQ errors on MYSQL - *germanotm*
|
6
|
+
|
7
|
+
### Misc
|
8
|
+
|
9
|
+
* Update matrix to only supported Rubies and Rails versions. Rails 5.2+ and Ruby 2.5+ are officially supported now.
|
10
|
+
|
1
11
|
## 0.4.2 (2019-11-01)
|
2
12
|
|
3
13
|
### Misc
|
data/Gemfile
CHANGED
@@ -8,24 +8,8 @@ rails = ENV['RAILS'] || '5-2'
|
|
8
8
|
db = ENV['DB'] || 'sqlite'
|
9
9
|
|
10
10
|
case rails
|
11
|
-
when '4-2'
|
12
|
-
gem 'activerecord', '~> 4.2.0'
|
13
|
-
when '5-1'
|
14
|
-
gem 'activerecord', '~> 5.1.0'
|
15
11
|
when '5-2'
|
16
12
|
gem 'activerecord', '~> 5.2.0'
|
17
13
|
when '6-0'
|
18
14
|
gem 'activerecord', '6.0.0'
|
19
15
|
end
|
20
|
-
|
21
|
-
case rails
|
22
|
-
when '4-2'
|
23
|
-
case ENV['DB']
|
24
|
-
when 'pg'
|
25
|
-
gem 'pg', '~> 0.18'
|
26
|
-
when 'mysql'
|
27
|
-
gem 'mysql2', '~> 0.3.18'
|
28
|
-
when 'sqlite'
|
29
|
-
gem 'sqlite3', '~> 1.3.0'
|
30
|
-
end
|
31
|
-
end
|
data/README.md
CHANGED
@@ -8,9 +8,9 @@ ActiveReporting implements various terminology used in Relational Online Analyti
|
|
8
8
|
|
9
9
|
ActiveReporting officially supports MySQL, PostgreSQL, and SQLite.
|
10
10
|
|
11
|
-
ActiveReporting officially supports Ruby 2.
|
11
|
+
ActiveReporting officially supports Ruby 2.5 and later. Other versions may work, but are not supported.
|
12
12
|
|
13
|
-
ActiveReporting officially supports Rails
|
13
|
+
ActiveReporting officially supports Rails 5.2, and 6.0. Other versions may work, but are not supported.
|
14
14
|
|
15
15
|
## Installation
|
16
16
|
|
@@ -49,8 +49,8 @@ Rails: ActiveRecord model
|
|
49
49
|
A dimension is a point of data used to "slice and dice" data from a fact model. It's either a column that lives on the fact table or a foreign key to another table.
|
50
50
|
|
51
51
|
Examples:
|
52
|
-
* A sales rep on a fact table of
|
53
|
-
* A state of an
|
52
|
+
* A sales rep on a fact table of sales
|
53
|
+
* A state of an sale on a state machine
|
54
54
|
* The manufacture on a fact table of widgets
|
55
55
|
|
56
56
|
SQL Equivalent: JOIN, GROUP BY
|
@@ -178,7 +178,7 @@ end
|
|
178
178
|
ActiveReporting assumes the column of a fact model used for summing, averaging, etc. is called `value`. This may be changed on a fact model using `measure=`. You may pass in a string or symbol of the column you wish to use for aggregations.
|
179
179
|
|
180
180
|
```ruby
|
181
|
-
class
|
181
|
+
class SaleFactModel < ActiveReporting::FactModel
|
182
182
|
self.measure = :total
|
183
183
|
end
|
184
184
|
```
|
@@ -273,8 +273,8 @@ A `Metric` is the basic building block used to describe a question you want to a
|
|
273
273
|
|
274
274
|
```ruby
|
275
275
|
my_metric = ActiveReporting::Metric.new(
|
276
|
-
:
|
277
|
-
fact_model:
|
276
|
+
:sale_total,
|
277
|
+
fact_model: SaleFactModel,
|
278
278
|
aggregate: :sum
|
279
279
|
)
|
280
280
|
```
|
@@ -285,7 +285,7 @@ my_metric = ActiveReporting::Metric.new(
|
|
285
285
|
|
286
286
|
`aggregate` - The SQL aggregate used to calculate the metric. Supported aggregates include count, max, min, avg, and sum. (Default: `:count`)
|
287
287
|
|
288
|
-
`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, {
|
288
|
+
`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, {sale_date: :month}]`). In hierarchies you can customize the label in this way: `[{sale_date: { field: :month, name: :a_custom_name_for_month }}]`. If you use a hash instead of a Symbol to define a hierarchy the `field` item must be a valid field in your table. The `name` can be whatever label you want.
|
289
289
|
|
290
290
|
`dimension_filter` - A hash were the keys are dimension filter names and the values are the values passed into the filter.
|
291
291
|
|
@@ -313,20 +313,20 @@ A `Report` takes an `ActiveReporting::Metric` and ties everything together. It i
|
|
313
313
|
|
314
314
|
```ruby
|
315
315
|
metric = ActiveReporting::Metric.new(
|
316
|
-
:
|
317
|
-
fact_model:
|
316
|
+
:sale_count,
|
317
|
+
fact_model: SaleFactModel,
|
318
318
|
dimensions: [:sales_rep],
|
319
319
|
dimension_filter: {months_ago: 1}
|
320
320
|
)
|
321
321
|
|
322
322
|
report = ActiveReporting::Report.new(metric)
|
323
323
|
report.run
|
324
|
-
=> [{
|
324
|
+
=> [{sale_count: 12, sales_rep: 'Fred Jones', sales_rep_identifier: 123},{sale_count: 17, sales_rep: 'Mary Sue', sales_rep_identifier: 123}]
|
325
325
|
```
|
326
326
|
|
327
327
|
A `Report` may also take additional arguments to merge with the `Metric`'s information. This can be user input for additional filters, or to expand on a base `Metric`.
|
328
328
|
|
329
|
-
`dimension_identifiers` - When true, the result will include the database identifier columns of the dimensions. For example, when running a report for the total number of
|
329
|
+
`dimension_identifiers` - When true, the result will include the database identifier columns of the dimensions. For example, when running a report for the total number of sales dimensioned by sales rep, the rep's IDs from the `sales_reps` table will be included. (Default `true`)
|
330
330
|
|
331
331
|
`dimension_filter` - A hash that will be merged with the `Metric`'s dimension filters.
|
332
332
|
|
@@ -336,15 +336,15 @@ A `Report` may also take additional arguments to merge with the `Metric`'s infor
|
|
336
336
|
|
337
337
|
```ruby
|
338
338
|
metric = ActiveReporting::Metric.new(
|
339
|
-
:
|
340
|
-
fact_model:
|
339
|
+
:sale_count,
|
340
|
+
fact_model: SaleFactModel,
|
341
341
|
dimensions: [:sales_rep],
|
342
342
|
dimension_filter: {months_ago: 1}
|
343
343
|
)
|
344
344
|
|
345
345
|
report = ActiveReporting::Report.new(metric, dimension_filter: {from_region: 'North'}, dimension_identifiers: false)
|
346
346
|
report.run
|
347
|
-
=> [{
|
347
|
+
=> [{sale_count: 17, sales_rep: 'Mary Sue'}]
|
348
348
|
```
|
349
349
|
|
350
350
|
It may be more DRY to store ready-made metrics in a database table or stored in memory to use as the bases for various reports. You can pass a string or symbol into a `Report` instead of a `Metric` to look up an pre-made metric. This is done by passing the symbol or string into the `lookup` class method on the constant defined in `ActiveReporting::Configuration.metric_lookup_class`.
|
data/active_reporting.gemspec
CHANGED
@@ -31,7 +31,7 @@ Gem::Specification.new do |spec|
|
|
31
31
|
spec.add_development_dependency 'minitest', '~> 5.0'
|
32
32
|
spec.add_development_dependency 'mysql2'
|
33
33
|
spec.add_development_dependency 'pg'
|
34
|
-
spec.add_development_dependency 'rake'
|
34
|
+
spec.add_development_dependency 'rake'
|
35
35
|
spec.add_development_dependency 'ransack'
|
36
36
|
spec.add_development_dependency 'sqlite3'
|
37
37
|
end
|
@@ -59,8 +59,8 @@ module ActiveReporting
|
|
59
59
|
def select_statement(with_identifier: true)
|
60
60
|
return [degenerate_select_fragment] if type == Dimension::TYPES[:degenerate]
|
61
61
|
|
62
|
-
ss = ["#{label_fragment} AS #{@label_name}"]
|
63
|
-
ss << "#{identifier_fragment} AS #{name}_identifier" if with_identifier
|
62
|
+
ss = ["#{label_fragment} AS #{model.connection.quote_column_name(@label_name)}"]
|
63
|
+
ss << "#{identifier_fragment} AS #{model.connection.quote_column_name("#{name}_identifier")}" if with_identifier
|
64
64
|
ss
|
65
65
|
end
|
66
66
|
|
@@ -150,11 +150,11 @@ module ActiveReporting
|
|
150
150
|
end
|
151
151
|
|
152
152
|
def identifier_fragment
|
153
|
-
"#{klass.quoted_table_name}.#{klass.primary_key}"
|
153
|
+
"#{klass.quoted_table_name}.#{model.connection.quote_column_name(klass.primary_key)}"
|
154
154
|
end
|
155
155
|
|
156
156
|
def label_fragment
|
157
|
-
"#{klass.quoted_table_name}.#{@label}"
|
157
|
+
"#{klass.quoted_table_name}.#{model.connection.quote_column_name(@label)}"
|
158
158
|
end
|
159
159
|
|
160
160
|
def dimension_fact_model
|
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.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tony Drake
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-07-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -98,16 +98,16 @@ dependencies:
|
|
98
98
|
name: rake
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
|
-
- - "
|
101
|
+
- - ">="
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version: '
|
103
|
+
version: '0'
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
|
-
- - "
|
108
|
+
- - ">="
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version: '
|
110
|
+
version: '0'
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: ransack
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -136,7 +136,7 @@ dependencies:
|
|
136
136
|
- - ">="
|
137
137
|
- !ruby/object:Gem::Version
|
138
138
|
version: '0'
|
139
|
-
description:
|
139
|
+
description:
|
140
140
|
email:
|
141
141
|
- t27duck@gmail.com
|
142
142
|
executables: []
|
@@ -170,7 +170,7 @@ homepage: https://github.com/t27duck/active_reporting
|
|
170
170
|
licenses:
|
171
171
|
- MIT
|
172
172
|
metadata: {}
|
173
|
-
post_install_message:
|
173
|
+
post_install_message:
|
174
174
|
rdoc_options: []
|
175
175
|
require_paths:
|
176
176
|
- lib
|
@@ -185,8 +185,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
185
185
|
- !ruby/object:Gem::Version
|
186
186
|
version: '0'
|
187
187
|
requirements: []
|
188
|
-
rubygems_version: 3.0.
|
189
|
-
signing_key:
|
188
|
+
rubygems_version: 3.0.3
|
189
|
+
signing_key:
|
190
190
|
specification_version: 4
|
191
191
|
summary: Add relational OLAP-like functionality for ActiveRecord
|
192
192
|
test_files: []
|