cache_key_for 0.1.5 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/cache_key_for/cache_key_for_helper.rb +9 -3
- data/lib/cache_key_for/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d793373a7919dfb8ffd28f2538db4b3b2095c84d
|
4
|
+
data.tar.gz: e7724aae76d14e231f430b8f9c8c1d4f24efbe59
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4a0a96ae20a85d30066805cc2e18bccfd5ac32c6cdc91aa74f205915acfc4b2167eff0a127c1dd856de4385188f9d67cdb235d237de43e079400eead27148583
|
7
|
+
data.tar.gz: 771f3129b4081a9883ef98564617e5b27bf85d254952fbba935c9e2b4764360d253dca269cf8fe6c9d9d8000c3cfc66d4bb7d68756709de89952ed22f98fcbd8
|
data/Gemfile.lock
CHANGED
@@ -43,11 +43,17 @@
|
|
43
43
|
# ```
|
44
44
|
module CacheKeyForHelper
|
45
45
|
def cache_key_for(scoped_collection, collection_prefix, cache_owner_cache_key = '', suffix = '', whitelist_params = [], default_params = {})
|
46
|
-
if scoped_collection.respond_to?(:maximum)
|
47
|
-
|
46
|
+
if scoped_collection.respond_to?(:maximum) # ActiveRecord
|
47
|
+
begin
|
48
|
+
max_updated_at = scoped_collection.maximum(scoped_collection.table_name + '.updated_at').to_f
|
49
|
+
# can't use join table as query root if query includes polimorphic associations
|
50
|
+
rescue ActiveRecord::EagerLoadPolymorphicError
|
51
|
+
Rails.logger.debug "[CacheKeyForHelper] Fallback to array (ActiveRecord::EagerLoadPolymorphicError)"
|
52
|
+
scoped_collection = scoped_collection.to_a
|
53
|
+
end
|
48
54
|
elsif scoped_collection.class == Array
|
49
55
|
max_updated_at = scoped_collection.to_a.map { |i| i.updated_at ? i.updated_at.utc.to_f : 0 }.max
|
50
|
-
elsif scoped_collection.respond_to?(:max)
|
56
|
+
elsif scoped_collection.respond_to?(:max) # Mongoid
|
51
57
|
max_updated_at = scoped_collection.max(:updated_at).to_f
|
52
58
|
end
|
53
59
|
count = scoped_collection.count
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cache_key_for
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marcin Kalita
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-07-
|
11
|
+
date: 2016-07-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: appraisal
|