services 2.2.3 → 2.2.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/lib/services/base_finder.rb +8 -10
- data/lib/services/modules/uniqueness_checker.rb +4 -4
- data/lib/services/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: bba562140a8277b78a80f08fc3da2ef986e9c809
|
4
|
+
data.tar.gz: b7dc8f429b69fcf41634603055c9424bf6533ce2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bc79aed015a6e7fb3170c046210ed0647d8ebc528fc9f32e436c6501e574c64c61a1ae791e9319c1577c4fedf4881a24cdfa07643d822a6316753dcaaa64fa00
|
7
|
+
data.tar.gz: d13742753844a6dfdf35b98324084ddf774de0561d9da7b49cef635fae36f8b010a629ed94a7ffa9df704df8cb047c9b225483025b33dc51e944c1383845d91d
|
data/CHANGELOG.md
CHANGED
data/lib/services/base_finder.rb
CHANGED
@@ -4,28 +4,26 @@ module Services
|
|
4
4
|
|
5
5
|
def call(ids = [], conditions = {})
|
6
6
|
ids, conditions = Array(ids), conditions.symbolize_keys
|
7
|
-
special_conditions = conditions.extract!(:order, :limit, :page, :per_page)
|
8
|
-
|
9
7
|
object_table_id = "#{object_class.table_name}.id"
|
10
8
|
|
9
|
+
special_conditions = conditions.extract!(:order, :limit, :page, :per_page)
|
10
|
+
special_conditions[:order] ||= object_table_id
|
11
|
+
|
11
12
|
scope = object_class.public_send(Rails::VERSION::MAJOR == 3 ? :scoped : :all)
|
12
13
|
scope = scope.where(object_table_id => ids) unless ids.empty?
|
13
14
|
|
14
15
|
unless conditions.empty?
|
15
|
-
scope = scope
|
16
|
-
.select("DISTINCT #{object_table_id}")
|
17
|
-
.order(object_table_id)
|
18
16
|
scope = process(scope, conditions)
|
19
|
-
scope = object_class.where(id: scope)
|
17
|
+
scope = object_class.where(id: scope.select("DISTINCT #{object_table_id}"))
|
20
18
|
end
|
21
19
|
|
22
20
|
special_conditions.each do |k, v|
|
23
21
|
case k
|
24
22
|
when :order
|
25
|
-
order =
|
26
|
-
|
27
|
-
|
28
|
-
|
23
|
+
order = case v
|
24
|
+
when 'random' then 'RANDOM()'
|
25
|
+
when /\./ then v
|
26
|
+
else "#{object_class.table_name}.#{v}"
|
29
27
|
end
|
30
28
|
scope = scope.order(order)
|
31
29
|
when :limit
|
@@ -14,7 +14,7 @@ module Services
|
|
14
14
|
)
|
15
15
|
|
16
16
|
MAX_RETRIES = 10
|
17
|
-
|
17
|
+
ONE_DAY = 60 * 60 * 24
|
18
18
|
|
19
19
|
def self.prepended(mod)
|
20
20
|
mod.const_set :NotUniqueError, Class.new(mod::Error)
|
@@ -37,7 +37,7 @@ module Services
|
|
37
37
|
else
|
38
38
|
@_uniqueness_keys ||= []
|
39
39
|
@_uniqueness_keys << new_uniqueness_key
|
40
|
-
Services.configuration.redis.setex new_uniqueness_key,
|
40
|
+
Services.configuration.redis.setex new_uniqueness_key, ONE_DAY, @id
|
41
41
|
true
|
42
42
|
end
|
43
43
|
end
|
@@ -62,7 +62,7 @@ module Services
|
|
62
62
|
raise "Unexpected on_error: #{@_on_error}"
|
63
63
|
end
|
64
64
|
ensure
|
65
|
-
Services.configuration.redis.del @_uniqueness_keys unless @_uniqueness_keys.
|
65
|
+
Services.configuration.redis.del @_uniqueness_keys unless Array(@_uniqueness_keys).empty?
|
66
66
|
Services.configuration.redis.del error_count_key
|
67
67
|
end
|
68
68
|
|
@@ -103,7 +103,7 @@ module Services
|
|
103
103
|
end
|
104
104
|
|
105
105
|
def increase_error_count
|
106
|
-
Services.configuration.redis.setex error_count_key, retry_delay +
|
106
|
+
Services.configuration.redis.setex error_count_key, retry_delay + ONE_DAY, error_count + 1
|
107
107
|
end
|
108
108
|
|
109
109
|
def uniqueness_key(args)
|
data/lib/services/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: services
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.2.
|
4
|
+
version: 2.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Manuel Meurer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-12-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|