ar_aggregate_by_interval 1.1.2 → 1.1.3
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/CHANGELOG.md +26 -0
- data/Gemfile +2 -1
- data/README.md +4 -1
- data/{ar_aggregate_counter.gemspec → ar_aggregate_by_interval.gemspec} +0 -0
- data/circle.yml +7 -0
- data/lib/ar_aggregate_by_interval/query_runner.rb +2 -1
- data/lib/ar_aggregate_by_interval/utils.rb +1 -1
- data/lib/ar_aggregate_by_interval/version.rb +1 -1
- data/lib/ar_aggregate_by_interval.rb +1 -0
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4beebc54e103e64f0d2ea5b3dc8947a033b4a217
|
4
|
+
data.tar.gz: d3f4008258eba648f009f37006d16b44d31475b6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5812bb1f2cbd9e838940e9e119db08126f244166d760796370b100e6913245b8665d3d4d3c6e4ca7a2f9fb5d7b8b37d1a7390dd1e345fde36d8a27b901f915d1
|
7
|
+
data.tar.gz: ccbb37c325b454a1fe4759a4f392fa8657054095fc13e2a3bd2eddc4b0307d351617b1243a4d07139efc8e4068334da1cea25a97c7ae208bcf7243f4a4f2d43e
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# Change Log
|
2
|
+
All notable changes to this project will be documented in this file.
|
3
|
+
This project adheres to [Semantic Versioning](http://semver.org/).
|
4
|
+
This file adheres to [Keep a changelog](http://keepachangelog.com/).
|
5
|
+
|
6
|
+
## [1.1.3] - 2015-03-02
|
7
|
+
### Fixed
|
8
|
+
- Fix Postgres queries due to AR injecting order clause
|
9
|
+
- Fix `daily` methods due to AR interpretting dates as Ruby date objects
|
10
|
+
- Allow running from IRB
|
11
|
+
|
12
|
+
## [1.1.2] - 2015-03-01
|
13
|
+
### Fixed
|
14
|
+
- Allow symbols to fix incorrect enforcement of strings for SQL columnn names
|
15
|
+
- Accept anything responding to `to_a` to fix inability to pass ActiveRecord associations (arrays) (as opposed to relations) to `QueryResult`
|
16
|
+
|
17
|
+
## [1.1.0] - 2015-03-01 (initial Gem release)
|
18
|
+
### Added
|
19
|
+
- Averages (`avg_daily`, `avg_weekly`, `avg_monthly`)
|
20
|
+
|
21
|
+
### Fixed
|
22
|
+
- Adjust the core `method_missing` to be included in `ActiveRecord::Relation` in addition to `ActiveRecord::Base` to fix running these functions on scoped ActiveRecord queries
|
23
|
+
- Correct inflector so *_daily methods stop raising exception
|
24
|
+
|
25
|
+
### Changed
|
26
|
+
- Gemified project
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,5 +1,8 @@
|
|
1
1
|
# ArAggregateByInterval
|
2
2
|
---
|
3
|
+
|
4
|
+
[](https://circleci.com/gh/jotto/ar_aggregate_by_interval)
|
5
|
+
|
3
6
|
Build arrays of counts, sums and averages from Ruby on Rails ActiveRecord models grouped by days, weeks or months. e.g.:
|
4
7
|
```ruby
|
5
8
|
# default 'group by' is 'created_at'
|
@@ -52,4 +55,4 @@ Billing.sum_weekly({
|
|
52
55
|
from: Time.zone.now.beginning_of_year,
|
53
56
|
to: Time.zone.now
|
54
57
|
}).values_and_dates
|
55
|
-
```
|
58
|
+
```
|
File without changes
|
data/circle.yml
ADDED
@@ -35,7 +35,8 @@ module ArAggregateByInterval
|
|
35
35
|
select("#{hash_args[:aggregate_function]}(#{hash_args[:aggregate_column] || '*'}) as totalchunked__").
|
36
36
|
select("#{db_vendor_select_for_date_function} as datechunk__").
|
37
37
|
group('datechunk__').
|
38
|
-
where(["#{hash_args[:group_by_column]} >= ? and #{hash_args[:group_by_column]} <= ?", from, to])
|
38
|
+
where(["#{hash_args[:group_by_column]} >= ? and #{hash_args[:group_by_column]} <= ?", from, to]).
|
39
|
+
order(nil)
|
39
40
|
|
40
41
|
# fill the gaps of the sql results
|
41
42
|
agg_int = QueryResult.new({
|
@@ -42,7 +42,7 @@ module ArAggregateByInterval
|
|
42
42
|
|
43
43
|
def ar_to_hash(ar_result, mapping)
|
44
44
|
ar_result.to_a.inject({}) do |memo, ar_obj|
|
45
|
-
mapping.each { |key, val| memo.merge!(ar_obj.send(key) => ar_obj.send(val)) }
|
45
|
+
mapping.each { |key, val| memo.merge!(ar_obj.send(key).to_s => ar_obj.send(val)) }
|
46
46
|
memo
|
47
47
|
end
|
48
48
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ar_aggregate_by_interval
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jonathan Otto
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-03-
|
11
|
+
date: 2015-03-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -146,12 +146,14 @@ extra_rdoc_files: []
|
|
146
146
|
files:
|
147
147
|
- ".gitignore"
|
148
148
|
- ".rspec"
|
149
|
+
- CHANGELOG.md
|
149
150
|
- Gemfile
|
150
151
|
- Guardfile
|
151
152
|
- LICENSE.txt
|
152
153
|
- README.md
|
153
154
|
- Rakefile
|
154
|
-
-
|
155
|
+
- ar_aggregate_by_interval.gemspec
|
156
|
+
- circle.yml
|
155
157
|
- lib/ar_aggregate_by_interval.rb
|
156
158
|
- lib/ar_aggregate_by_interval/query_result.rb
|
157
159
|
- lib/ar_aggregate_by_interval/query_runner.rb
|