toast 1.1.0 → 1.1.1

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: 7b13e469679d7d7b0d50207808e3b03a634d8ea3
4
- data.tar.gz: d61fdc8ec1c63c7c1b45bedc0d79930d07d5574d
3
+ metadata.gz: f9a6abb704a427b250f834207658a733b8bacedf
4
+ data.tar.gz: 2d7994ff30427fc8e1bfa1eb5cff1be83019f7e6
5
5
  SHA512:
6
- metadata.gz: 80e314e9b379d2766b966651a0bb62777907823572ffbd6ad15353bcee9de63043ad078f85f320a148394c2e722a9c9b454a127483fe00c9e55e73699388c0ed
7
- data.tar.gz: bd67aa8501fc98050bd51b910388659dfa380c696a6abfb980779e673d01a89c85db08042f4be7d4876226c89eb8a2b25b092247acf46789a4a49d1bbcead56c
6
+ metadata.gz: d791670e8698a667d462841d2ff374f84fa71b355131796cf0547d57a78a12f523115cc327d6e52cf22f467a66f7724361736c536cade3a51e6fdc03a47de3fe
7
+ data.tar.gz: 23be4cf6a59aa885c470f59de9bffe88d323d7075a9370e8a1d2913313f5bcfceaac54f9575f2c6caefc3cc78fc339ada92680ace8f6d47779fc97262e98f32e
@@ -49,14 +49,11 @@ class Toast::CollectionRequest
49
49
  @auth, relation, @uri_params)
50
50
 
51
51
  if relation.is_a?(ActiveRecord::Relation) and
52
- relation.model.name == @config.base_model_class.name
52
+ relation.model== @config.base_model_class
53
53
 
54
54
  result = relation.limit(window).offset(range_start)
55
55
 
56
- # count = relation.count doesn't always work
57
- # fix problematic select extensions for counting (-> { select(...) })
58
- # this fails if the where clause depends on the the extended select
59
- count = relation.count_by_sql relation.to_sql.sub(/SELECT.+FROM/,'SELECT COUNT(*) FROM')
56
+ count = relation.unscope(:select).select(:id).count
60
57
  headers = {"Content-Type" => @config.media_type}
61
58
 
62
59
  if count > 0
@@ -67,8 +67,7 @@ class Toast::PluralAssocRequest
67
67
  # this fails if the where clause depends on the the extended select
68
68
  # also remove any ORDER clauses
69
69
 
70
- # How can we do this with the ActiveRecord API in a cleaner way?
71
- count = relation.count_by_sql relation.to_sql.sub(/SELECT.+FROM/,'SELECT COUNT(*) FROM').sub(/ORDER BY.*/,'')
70
+ count = relation.unscope(:select).select(:id).count
72
71
  headers = {"Content-Type" => @config.media_type}
73
72
 
74
73
  if count > 0
@@ -1,3 +1,3 @@
1
1
  module Toast
2
- VERSION = '1.1.0'
2
+ VERSION = '1.1.1'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: toast
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - robokopp (Robert Annies)
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-05-06 00:00:00.000000000 Z
11
+ date: 2019-05-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails