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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1e3f42f5b3d4869497acf2e3405f0f278b25582d
4
- data.tar.gz: 8c4d047373b919125c3117da284fd345f7a81816
3
+ metadata.gz: bba562140a8277b78a80f08fc3da2ef986e9c809
4
+ data.tar.gz: b7dc8f429b69fcf41634603055c9424bf6533ce2
5
5
  SHA512:
6
- metadata.gz: 3c776d68b4a336b6a7a04a0003137a176447d1a13a0061c25d3e78806b2243ee81c1cec2a46951be2713acabef16d734681a911cb81eb2ca4a2667b5ea1ae4df
7
- data.tar.gz: 933e0c58c79076b20ab1448b7c6105154703b5aea272ef590d17002d4b092fea4cc5149fd385d1b8d1d6c1af7114fa6446501ef104ac141ec09ed58a4e95a4db
6
+ metadata.gz: bc79aed015a6e7fb3170c046210ed0647d8ebc528fc9f32e436c6501e574c64c61a1ae791e9319c1577c4fedf4881a24cdfa07643d822a6316753dcaaa64fa00
7
+ data.tar.gz: d13742753844a6dfdf35b98324084ddf774de0561d9da7b49cef635fae36f8b010a629ed94a7ffa9df704df8cb047c9b225483025b33dc51e944c1383845d91d
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ ## 2.2.4
2
+
3
+ * Increase TTL for Redis keys for uniqueness and error count to one day
4
+ * Fix ordering in `BaseFinder`
5
+
1
6
  ## 2.2.3
2
7
 
3
8
  * Add `on_error` option `return` to uniqueness checker
@@ -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 = if v == 'random'
26
- 'RANDOM()'
27
- else
28
- "#{object_class.table_name}.#{v}"
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
- ONE_HOUR = 60 * 60
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, ONE_HOUR, @id
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.nil? || @_uniqueness_keys.empty?
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 + ONE_HOUR, error_count + 1
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)
@@ -1,3 +1,3 @@
1
1
  module Services
2
- VERSION = '2.2.3'
2
+ VERSION = '2.2.4'
3
3
  end
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.3
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-28 00:00:00.000000000 Z
11
+ date: 2014-12-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake