active_reporting 0.6.1 → 0.6.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bd8ff0998a757ff875a17baad2fcb148ace4239da0781e1b7fbdd4c6367cef2c
4
- data.tar.gz: 316ee68af897e1b866b79b28d3f0889f116982a48b94a123cde5170ac851b4e1
3
+ metadata.gz: bc7dff49fb9bffe3ea663751a710d20343a8dd6a218a088433e772884ab3412b
4
+ data.tar.gz: 9c03f8ed6f0247d911da6290b120c8b74643cc780761585cd8b0b85ef4a55ff3
5
5
  SHA512:
6
- metadata.gz: 73f92eed3389912530e9ff393e761bbc6e86a84e1c6beff4428de03f295a2fe91f2b230d25d8a3d0b783761b099dca43b4bc62ea05538a469c925eae5c9044d2
7
- data.tar.gz: b1217306b02aa8e40b78cea0d0d31dca84621c4b676e79a638bf8644891e301a3d850e2f645d9c0b745724c4a03c0837936cbe1776e9794a89e4e73580589256
6
+ metadata.gz: 4c48dae4c7a6a5389241ef0ee3d01038073d2c75582b8b60aaa93be0e41a3e70abc84f87d609071bca9e86b72968a842f65af199d1a7f7f84e8c449ab720cf9e
7
+ data.tar.gz: 003b8752db40a55ac09dde37d6f32d21bc14d921c88011393339b4f59554dedfe10557d49545f929d5ea1c7f5a64911fd1fda9fc5bf0d67823e9b68eae9396c1
@@ -0,0 +1,11 @@
1
+ # To get started with Dependabot version updates, you'll need to specify which
2
+ # package ecosystems to update and where the package manifests are located.
3
+ # Please see the documentation for all configuration options:
4
+ # https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
5
+
6
+ version: 2
7
+ updates:
8
+ - package-ecosystem: "github-actions"
9
+ directory: "/"
10
+ schedule:
11
+ interval: "weekly"
@@ -0,0 +1,150 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - main
7
+ pull_request:
8
+ branches:
9
+ - main
10
+
11
+ env:
12
+ POSTGRES_USER: postgres
13
+ POSTGRES_PASSWORD: postgres
14
+ PGPASSWORD: postgres
15
+ POSTGRES_HOST: localhost
16
+ MYSQL_HOST: '127.0.0.1'
17
+ MYSQL_USER: 'root'
18
+
19
+ jobs:
20
+ tests:
21
+ services:
22
+ pg:
23
+ image: postgres:12
24
+ env:
25
+ POSTGRES_USER: postgres
26
+ POSTGRES_PASSWORD: postgres
27
+ ports: ['5432:5432']
28
+ mysql:
29
+ image: mysql:5.7
30
+ env:
31
+ MYSQL_ALLOW_EMPTY_PASSWORD: yes
32
+ MYSQL_DATABASE: active_reporting_test
33
+ ports:
34
+ - 3306
35
+
36
+ runs-on: ubuntu-latest
37
+ strategy:
38
+ fail-fast: false
39
+ matrix:
40
+ include:
41
+ - ruby: '3.0'
42
+ gemfile: '6.1'
43
+ db: 'mysql'
44
+
45
+ - ruby: '3.0'
46
+ gemfile: '6.1'
47
+ db: 'pg'
48
+
49
+ - ruby: '3.0'
50
+ gemfile: '6.1'
51
+ db: 'sqlite'
52
+
53
+ - ruby: '3.0'
54
+ gemfile: '7.0'
55
+ db: 'mysql'
56
+
57
+ - ruby: '3.0'
58
+ gemfile: '7.0'
59
+ db: 'pg'
60
+
61
+ - ruby: '3.0'
62
+ gemfile: '7.0'
63
+ db: 'sqlite'
64
+
65
+ - ruby: '3.1'
66
+ gemfile: '7.0'
67
+ db: 'mysql'
68
+
69
+ - ruby: '3.1'
70
+ gemfile: '7.0'
71
+ db: 'pg'
72
+
73
+ - ruby: '3.1'
74
+ gemfile: '7.0'
75
+ db: 'sqlite'
76
+
77
+ - ruby: '3.2'
78
+ gemfile: '7.0'
79
+ db: 'mysql'
80
+
81
+ - ruby: '3.2'
82
+ gemfile: '7.0'
83
+ db: 'pg'
84
+
85
+ - ruby: '3.2'
86
+ gemfile: '7.0'
87
+ db: 'sqlite'
88
+
89
+ - ruby: '3.3'
90
+ gemfile: '7.0'
91
+ db: 'mysql'
92
+
93
+ - ruby: '3.3'
94
+ gemfile: '7.0'
95
+ db: 'pg'
96
+
97
+ - ruby: '3.3'
98
+ gemfile: '7.0'
99
+ db: 'sqlite'
100
+
101
+ - ruby: '3.2'
102
+ gemfile: '7.1'
103
+ db: 'mysql'
104
+
105
+ - ruby: '3.2'
106
+ gemfile: '7.1'
107
+ db: 'pg'
108
+
109
+ - ruby: '3.2'
110
+ gemfile: '7.1'
111
+ db: 'sqlite'
112
+
113
+ - ruby: '3.3'
114
+ gemfile: '7.1'
115
+ db: 'mysql'
116
+
117
+ - ruby: '3.3'
118
+ gemfile: '7.1'
119
+ db: 'pg'
120
+
121
+ - ruby: '3.3'
122
+ gemfile: '7.1'
123
+ db: 'sqlite'
124
+ name: rails ${{ matrix.gemfile }}, ruby ${{ matrix.ruby }}, ${{ matrix.db }}
125
+
126
+ steps:
127
+ - uses: actions/checkout@v4
128
+
129
+ - name: Set up Ruby
130
+ uses: ruby/setup-ruby@v1
131
+ with:
132
+ ruby-version: ${{ matrix.ruby }}
133
+ bundler-cache: false
134
+
135
+ - name: Bundle install
136
+ env:
137
+ DB: ${{ matrix.db }}
138
+ RAILS: ${{ matrix.gemfile }}
139
+ run: |
140
+ bundle install --jobs 4 --retry 3
141
+ - name: Create PG DB
142
+ run: |
143
+ psql -c 'create database active_reporting_test;' -U postgres -h localhost
144
+ - name: Run tests
145
+ env:
146
+ MYSQL_PORT: ${{ job.services.mysql.ports['3306'] }}
147
+ DB: ${{ matrix.db }}
148
+ RAILS: ${{ matrix.gemfile }}
149
+ run: |
150
+ bundle exec rake test
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## 0.6.2 (2024-03-18)
2
+
3
+ ### Features
4
+
5
+ * `Metric` can now take an optional `measure` argument to override the measure that would normally be used.
6
+
1
7
  ## 0.6.1 (2020-08-29)
2
8
 
3
9
  ### Misc
data/Gemfile CHANGED
@@ -4,12 +4,14 @@ gemspec
4
4
 
5
5
  gem 'simplecov', require: false
6
6
 
7
- rails = ENV['RAILS'] || '5-2'
7
+ rails = ENV['RAILS'] || '6.1'
8
8
  db = ENV['DB'] || 'sqlite'
9
9
 
10
10
  case rails
11
- when '5-2'
12
- gem 'activerecord', '~> 5.2.0'
13
- when '6-0'
14
- gem 'activerecord', '~> 6.0.0'
11
+ when '6.1'
12
+ gem 'activerecord', '~> 6.1.0'
13
+ when '7.0'
14
+ gem 'activerecord', '~> 7.0.0'
15
+ when '7.1'
16
+ gem 'activerecord', '~> 7.1.0'
15
17
  end
data/README.md CHANGED
@@ -1,6 +1,4 @@
1
- [![Build Status](https://travis-ci.org/t27duck/active_reporting.svg?branch=master)](https://travis-ci.org/t27duck/active_reporting)
2
-
3
- [![Code Climate](https://codeclimate.com/github/t27duck/active_reporting/badges/gpa.svg)](https://codeclimate.com/github/t27duck/active_reporting)
1
+ ![Build Status](https://github.com/t27duck/active_reporting/workflows/CI/badge.svg)
4
2
 
5
3
  # ActiveReporting
6
4
 
@@ -8,9 +6,9 @@ ActiveReporting implements various terminology used in Relational Online Analyti
8
6
 
9
7
  ActiveReporting officially supports MySQL, PostgreSQL, and SQLite.
10
8
 
11
- ActiveReporting officially supports Ruby 2.5 and later. Other versions may work, but are not supported.
9
+ ActiveReporting officially supports Ruby 3.0 and later. Other versions may work, but are not supported.
12
10
 
13
- ActiveReporting officially supports Rails 5.2, and 6.0. Other versions may work, but are not supported.
11
+ ActiveReporting officially supports Rails 6.1 - 7.1. Other versions may work, but are not supported.
14
12
 
15
13
  ## Installation
16
14
 
@@ -308,7 +306,7 @@ my_metric = ActiveReporting::Metric.new(
308
306
 
309
307
  You may pass a hash instead of a symbol to customize the dimension options (example: { dimension_name: { option1: value, option2: value}}). The avaliable options are:
310
308
 
311
- - `field` - Specify the hierarchy level that should be used instead the default dimension label. Ex: `[:sales_rep, {mobile_phone: { field :manufacture }}]`. If you use a hash instead of a Symbol to define a hierarchy the `field` item must be a valid field in your table.
309
+ - `field` - Specify the hierarchy level that should be used instead the default dimension label. Ex: `[:sales_rep, {mobile_phone: { field: :manufacture }}]`. If you use a hash instead of a Symbol to define a hierarchy the `field` item must be a valid field in your table.
312
310
 
313
311
  - `name` - You may costumize the label alias, by default the dimension name will be used. The `name` can be whatever label you want. Ex :`[{sale_date: { field: :month, name: :a_custom_name_for_month }}]`.
314
312
 
@@ -320,6 +318,8 @@ You may pass a hash instead of a symbol to customize the dimension options (exam
320
318
 
321
319
  `metric_filter` - An additional HAVING clause to be tacked on to the end of the query. This allows for the further filtering of the end results based on the value of the aggregate. (Examples: `{gt: 3}`, `{eq: 5}`, `{lte: 7}`)
322
320
 
321
+ `measure` - Override the measure on the `ActiveReporting::Factmodel` used.
322
+
323
323
  `order_by_dimension` - Allows you to set the ordering of the results based on a dimension label. (Examples: `{author: :desc}`, `{sales_ref: :asc}`)
324
324
 
325
325
  For those using Postgres, you can take advantage of implicit hierarchies in `datetime` columns, as mentioned above:
@@ -7,7 +7,8 @@ module ActiveReporting
7
7
  class Metric
8
8
  extend Forwardable
9
9
  def_delegators :@fact_model, :model
10
- attr_reader :fact_model, :name, :dimensions, :dimension_filter, :aggregate, :metric_filter, :order_by_dimension
10
+ attr_reader :fact_model, :name, :dimensions, :dimension_filter, :aggregate
11
+ attr_reader :metric_filter, :order_by_dimension, :measure
11
12
 
12
13
  def initialize(
13
14
  name,
@@ -16,7 +17,8 @@ module ActiveReporting
16
17
  dimensions: [],
17
18
  dimension_filter: {},
18
19
  metric_filter: {},
19
- order_by_dimension: {}
20
+ order_by_dimension: {},
21
+ measure: nil
20
22
  )
21
23
  @name = name.to_sym
22
24
  @fact_model = fact_model
@@ -25,6 +27,7 @@ module ActiveReporting
25
27
  @metric_filter = metric_filter
26
28
  @dimensions = ReportingDimension.build_from_dimensions(@fact_model, Array(dimensions))
27
29
  @order_by_dimension = order_by_dimension
30
+ @measure = measure
28
31
  check_dimension_filter
29
32
  end
30
33
 
@@ -81,10 +81,14 @@ module ActiveReporting
81
81
  when :count
82
82
  'COUNT(*)'
83
83
  else
84
- "#{@metric.aggregate.to_s.upcase}(#{fact_model.measure})"
84
+ "#{@metric.aggregate.to_s.upcase}(#{measure})"
85
85
  end
86
86
  end
87
87
 
88
+ def measure
89
+ @metric.measure || fact_model.measure
90
+ end
91
+
88
92
  def dimension_joins(join_method)
89
93
  @dimensions.select { |d| d.type == Dimension::TYPES[:standard] && d.join_method == join_method }.
90
94
  map { |d| d.name.to_sym }
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ActiveReporting
4
- VERSION = '0.6.1'
4
+ VERSION = '0.6.2'
5
5
  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.6.1
4
+ version: 0.6.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tony Drake
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-08-29 00:00:00.000000000 Z
11
+ date: 2024-03-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -143,10 +143,10 @@ executables: []
143
143
  extensions: []
144
144
  extra_rdoc_files: []
145
145
  files:
146
- - ".codeclimate.yml"
146
+ - ".github/dependabot.yml"
147
+ - ".github/workflows/tests.yml"
147
148
  - ".gitignore"
148
149
  - ".rubocop.yml"
149
- - ".travis.yml"
150
150
  - CHANGELOG.md
151
151
  - CODE_OF_CONDUCT.md
152
152
  - Gemfile
@@ -185,7 +185,7 @@ 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.3
188
+ rubygems_version: 3.5.3
189
189
  signing_key:
190
190
  specification_version: 4
191
191
  summary: Add relational OLAP-like functionality for ActiveRecord
data/.codeclimate.yml DELETED
@@ -1,15 +0,0 @@
1
- engines:
2
- duplication:
3
- enabled: true
4
- config:
5
- languages:
6
- - ruby
7
- fixme:
8
- enabled: true
9
- rubocop:
10
- enabled: true
11
- ratings:
12
- paths:
13
- - "**.rb"
14
- exclude_paths:
15
- - test/
data/.travis.yml DELETED
@@ -1,20 +0,0 @@
1
- sudo: false
2
- language: ruby
3
- services:
4
- - mysql
5
- addons:
6
- postgresql: "9.6"
7
- rvm:
8
- - 2.5.8
9
- - 2.6.6
10
- - 2.7.1
11
- env:
12
- - RAILS=6-0 DB=sqlite
13
- - RAILS=6-0 DB=pg
14
- - RAILS=6-0 DB=mysql
15
- - RAILS=5-2 DB=sqlite
16
- - RAILS=5-2 DB=pg
17
- - RAILS=5-2 DB=mysql
18
- before_script:
19
- - psql -c 'create database active_reporting_test;' -U postgres
20
- - mysql -e 'create database active_reporting_test collate utf8_general_ci;'