active_hash_relation 0.0.3 → 1.0.0

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
  SHA1:
3
- metadata.gz: c46ec26a67f7a3de70d6ea616c729d074b24b3c6
4
- data.tar.gz: 77fcb4801781ce42b1b131897f512a27e99c14c4
3
+ metadata.gz: 9e8a15147af3c9b53fa1edadbd8a6d73c1032dfa
4
+ data.tar.gz: caa04edc9050cd929d30ca023004c34618b6316c
5
5
  SHA512:
6
- metadata.gz: fd1dd4b024765dacd505e2bf4b035ccfc5949c457404e650bbd2a0dc9cdd88bcdc1a661651a4a4d8476afb7309e5aed2920aedda563643bc37d64dbd6d358494
7
- data.tar.gz: 467857eaaa1c5742190b336f36489d206a3ae59d068f4540948ad9f39a296bc479a5bed3c052e01c9495c71af687d14caf8f0d46d916c065aeed5c24790e19db
6
+ metadata.gz: a37b985fbebea7efd854ac282a60308b62ac67d994fdc2f204d4bfdc06c1e328b749126b4e952c40220e200718bbb53eda434d2aa734c499121ba251493f61ab
7
+ data.tar.gz: 2ae6c59dacc4aafe54b4eb441b38b17434a2986aa6e9fe9be7f4493ff5e4d1d7067ec45306e09d6b8f24e2e70a9f7abe5821073b94e1f8350e97122ff9aa2115
data/README.md CHANGED
@@ -21,9 +21,9 @@ underneath with the same params.
21
21
  _\*Actually nothing is exposed, but a user could retrieve resources based
22
22
  on unknown attributes (attributes not returned from the API) by brute forcing
23
23
  which might or might not be a security issue. If you don't like that check
24
- [whitelisting](https://github.com/kollegorna/active_hash_relation#whitelisting)._
24
+ [whitelisting](#whitelisting)._
25
25
 
26
- *New*! You can now do [__aggregation queries__](https://github.com/kollegorna/active_hash_relation#aggregation_queries).
26
+ *New*! You can now do [__aggregation queries__](#aggregation-queries).
27
27
 
28
28
  ## Installation
29
29
 
@@ -149,7 +149,7 @@ called to apply the filters in resource association.
149
149
  Sometimes we need to ask the database queries that act on the collection but don't want back an array of elements but a value instead! Now you can do that on an ActiveRecord::Relation by simply calling the aggregations method inside the controller:
150
150
 
151
151
  ```ruby
152
- apply_filters(resource, {
152
+ aggregations(resource, {
153
153
  aggregate: {
154
154
  integer_column: { avg: true, max: true, min: true, sum: true },
155
155
  float_column: {avg: true, max: true, min: true },
@@ -165,7 +165,7 @@ and you will get a hash (HashWithIndifferentAccess) back that holds all your agg
165
165
  "datetime_at"=>{"max"=>2015-06-11 20:59:14 UTC, "min"=>2015-06-11 20:59:12 UTC}}
166
166
  ```
167
167
 
168
- These attributes usually go to the "meta" section of your serializer. In that way it's easy to parse them in the front-end (for ember check [here](http://guides.emberjs.com/v1.10.0/models/handling-metadata/). Please note that you should apply the aggregations __after__ you apply the filters, if there any.
168
+ These attributes usually go to the "meta" section of your serializer. In that way it's easy to parse them in the front-end (for ember check [here](http://guides.emberjs.com/v1.10.0/models/handling-metadata/)). Please note that you should apply the aggregations __after__ you apply the filters (if there any) but __before__ you apply pagination!
169
169
 
170
170
 
171
171
 
@@ -46,7 +46,7 @@ module ActiveHashRelation
46
46
  meta_attributes = HashWithIndifferentAccess.new
47
47
 
48
48
  available_aggr.each do |k, v|
49
- if asked_aggr[k] == true
49
+ if asked_aggr[k]
50
50
  meta_attributes[k] = resource.send(v,column)
51
51
  meta_attributes[k] = meta_attributes[k].to_f if meta_attributes[k].is_a? BigDecimal
52
52
  end
@@ -56,15 +56,15 @@ module ActiveHashRelation::ColumnFilters
56
56
  private
57
57
 
58
58
  def apply_leq_geq_le_ge_filters(resource, table_name, column, param)
59
- if param[:leq]
59
+ if !param[:leq].blank?
60
60
  resource = resource.where("#{table_name}.#{column} <= ?", param[:leq])
61
- elsif param[:le]
61
+ elsif !param[:le].blank?
62
62
  resource = resource.where("#{table_name}.#{column} < ?", param[:le])
63
63
  end
64
64
 
65
- if param[:geq]
65
+ if !param[:geq].blank?
66
66
  resource = resource.where("#{table_name}.#{column} >= ?", param[:geq])
67
- elsif param[:ge]
67
+ elsif !param[:ge].blank?
68
68
  resource = resource.where("#{table_name}.#{column} > ?", param[:ge])
69
69
  end
70
70
 
@@ -24,7 +24,7 @@ module ActiveHashRelation
24
24
  end
25
25
  table_name = @model.table_name
26
26
  @model.columns.each do |c|
27
- next if @params[c.name.to_s].nil?
27
+ next if @params[c.name.to_s].blank?
28
28
 
29
29
  if c.respond_to?(:primary)
30
30
  if c.primary
@@ -1,3 +1,3 @@
1
1
  module ActiveHashRelation
2
- VERSION = "0.0.3"
2
+ VERSION = "1.0.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_hash_relation
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Filippos Vasilakis
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-06-11 00:00:00.000000000 Z
11
+ date: 2015-09-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -83,7 +83,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
83
83
  version: '0'
84
84
  requirements: []
85
85
  rubyforge_project:
86
- rubygems_version: 2.4.5
86
+ rubygems_version: 2.4.8
87
87
  signing_key:
88
88
  specification_version: 4
89
89
  summary: Simple gem that allows you to run multiple ActiveRecord::Relation using hash.