ruote-ar 0.0.14 → 0.0.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/ruote/ar/storage.rb +3 -9
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1e0241507f892fff44c2ebdaf0d9d9c9e44b944a
|
4
|
+
data.tar.gz: 0de91883cd70078a934cb5f574d894e889e99568
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 47fbd6cad6db3761cf3333dc03ae57e77b54c1b5a1f93f02171adbbdd5c7fb01f2b3999785b8462efffc6418707300f5a9595e9f6e09f52d9958ee42229e781b
|
7
|
+
data.tar.gz: 3cd4e2c7e841552352d763f6f7e8e0d8ff2eb2c7ce04bdb845e3341e76d66d26302699e303b03ccec70889e0d31dc528dd0474bc5e1a5c4d398865ac1e48f9d7
|
data/lib/ruote/ar/storage.rb
CHANGED
@@ -34,10 +34,6 @@ module Ruote
|
|
34
34
|
# return true if the update was affected more than one line.
|
35
35
|
#
|
36
36
|
def reserve(doc)
|
37
|
-
# doc is already this worker
|
38
|
-
return true if !doc['_worker'].nil? && doc['_worker'] == @worker
|
39
|
-
|
40
|
-
# try reserve this document
|
41
37
|
um = Arel::UpdateManager.new Arel::Table.engine
|
42
38
|
um.table table
|
43
39
|
um.where table[:typ].eq(doc['type'].to_s).
|
@@ -134,8 +130,8 @@ module Ruote
|
|
134
130
|
|
135
131
|
keys = key ? Array(key) : nil
|
136
132
|
ds = ds.and(table[:wfid].in(keys)) if keys && keys.first.is_a?(String)
|
137
|
-
ds = ds.and(table[:worker].eq(nil)
|
138
|
-
|
133
|
+
ds = ds.and(table[:worker].eq(nil)) if type == 'msgs'
|
134
|
+
|
139
135
|
ds = table.where(ds)
|
140
136
|
|
141
137
|
return connection.select_value(ds.project(table[:wfid].count)) if opts[:count]
|
@@ -154,9 +150,7 @@ module Ruote
|
|
154
150
|
|
155
151
|
docs = connection.select_all(ds.project('*'))
|
156
152
|
docs = select_last_revs(docs)
|
157
|
-
|
158
|
-
# TIP: append worker info to doc to use in reserve
|
159
|
-
docs = docs.collect { |d| Rufus::Json.decode(d['doc']).merge({'_worker' => d['worker']}) }
|
153
|
+
docs = docs.collect { |d| Rufus::Json.decode(d['doc']) }
|
160
154
|
|
161
155
|
if keys && keys.first.is_a?(Regexp)
|
162
156
|
docs.select { |doc| keys.find { |k| k.match(doc['_id']) } }
|