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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 600ccd6f3d13f4614f3be8a977397114501d1587
4
- data.tar.gz: 00eff7b135ab7af2bf368cad7c46ccc6a6e40bd6
3
+ metadata.gz: 4beebc54e103e64f0d2ea5b3dc8947a033b4a217
4
+ data.tar.gz: d3f4008258eba648f009f37006d16b44d31475b6
5
5
  SHA512:
6
- metadata.gz: ba67a323ed7e60c81d39cf2c751b2fe3c696bd51be706470bd567efdc90603bd8cd805fda3dfe155157a833bc9b957fa1bbd072eb274377549636f3f87e8b19f
7
- data.tar.gz: 13c00d4056ea7d4fd49d2b4a12545f8a378614b21e1e427d6c1330e9f69ed1f4a75b8923049d85c4deda9423158560ad1d632050ffc80880baa708bb617c7e09
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
@@ -1,2 +1,3 @@
1
1
  source 'https://rubygems.org'
2
- gemspec
2
+ ruby '2.2.0'
3
+ gemspec
data/README.md CHANGED
@@ -1,5 +1,8 @@
1
1
  # ArAggregateByInterval
2
2
  ---
3
+
4
+ [![Circle CI](https://circleci.com/gh/jotto/ar_aggregate_by_interval.svg?style=svg)](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
+ ```
data/circle.yml ADDED
@@ -0,0 +1,7 @@
1
+ database:
2
+ override:
3
+ - ls # no op
4
+
5
+ test:
6
+ override:
7
+ - bundle exec rake
@@ -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
@@ -1,3 +1,3 @@
1
1
  module ArAggregateByInterval
2
- VERSION = '1.1.2'
2
+ VERSION = '1.1.3'
3
3
  end
@@ -1,3 +1,4 @@
1
+ require 'active_record'
1
2
  require 'ar_aggregate_by_interval/query_runner'
2
3
  require 'ar_aggregate_by_interval/utils'
3
4
 
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.2
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-01 00:00:00.000000000 Z
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
- - ar_aggregate_counter.gemspec
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