postjob 0.4.3 → 0.4.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: 0be2321073faba782e89878c47c6c6770b97e7ff
4
- data.tar.gz: c9d3cf35e02a4105587d5888535e4297d4abb9af
3
+ metadata.gz: 3db8f37270f64683adc0ef25167f8198cb93e681
4
+ data.tar.gz: 323f1a09174b3364e8776c2e59e8a9fad9e22708
5
5
  SHA512:
6
- metadata.gz: 208afca0daf608d1ada39ad4fac5539e2ad10388d73e469bc4164eee2f49c4615a0e845578dd1aad5db6fe33f0decdef62c0329b198fa4f44f2e9941363eb2e7
7
- data.tar.gz: 11a854fb585336169a6b218884d8b02503c5e52503efac95609b937dc18dd51703868f93a569f3fb66b557c411215bf9ecf797f5ddd33a4781a750092676855f
6
+ metadata.gz: d22d0304488080812e9f3b967462867b45d1b51c8eb7733bcace9f4f5bfb2a60db95a70c335f71c393e23077a0a30bc0bbca80731783dac5aeebf93f18536b1f
7
+ data.tar.gz: a261688942b25f1c1c07870d500138d4a601663e18e081ae4a4d09e756ff0e30f246da60fe2669f7b40adaf9dc271998e6d80a130c0dde5001bbaa87f5300ce1
@@ -43,15 +43,12 @@ module Postjob::Queue
43
43
 
44
44
  column_filters, tags_filters = filter.partition { |key, _| column_names.include?(key) }
45
45
 
46
- scope = column_filters.inject(scope) do |sc, (key, value)|
47
- sc.where(key => value)
48
- end
49
-
50
- unless tags_filters.empty?
51
- tags_filters = Hash[tags_filters]
52
- scope = scope.where "tags @> '#{Postjob::Queue::Encoder.encode(tags_filters)}'"
53
- end
54
-
46
+ scope = scope.where(Hash[column_filters])
47
+ scope = scope.where(tags: Hash[tags_filters])
55
48
  scope
56
49
  end
50
+
51
+ def apply_tag_filters(scope, filters)
52
+ scope.where(tags: Hash[filters])
53
+ end
57
54
  end
@@ -26,7 +26,7 @@ describe "Postjob::Queue.search" do
26
26
  Simple::SQL.ask("DELETE FROM postjob.postjobs")
27
27
  end
28
28
 
29
- let!(:id) { Postjob.enqueue! "SearchWorkflow", tags: { "initial" => "yay" } }
29
+ let!(:id) { Postjob.enqueue! "SearchWorkflow", tags: { "initial" => "yay", "multi" => "manyay" } }
30
30
 
31
31
  Queue = Postjob::Queue
32
32
 
@@ -103,5 +103,31 @@ describe "Postjob::Queue.search" do
103
103
  result = Simple::SQL.all(scope)
104
104
  expect(result.length).to eq(0)
105
105
  end
106
+
107
+ it "filter tags against empty array" do
108
+ scope = Postjob::Queue.search("initial" => [])
109
+ result = Simple::SQL.all(scope)
110
+ expect(result.length).to eq(0)
111
+ end
112
+
113
+ it "filter tags against multiple matches" do
114
+ scope = Postjob::Queue.search("initial" => [ "yay", "nay" ])
115
+ result = Simple::SQL.all(scope)
116
+ expect(result.length).to eq(1)
117
+ end
118
+
119
+ it "filter tags against a combination of multiple matches" do
120
+ scope = Postjob::Queue.search("initial" => [ "yay", "nay" ], "multi" => "manyay")
121
+ result = Simple::SQL.all(scope)
122
+ expect(result.length).to eq(1)
123
+
124
+ scope = Postjob::Queue.search("initial" => [ "yay", "nay" ], "multi" => "nay")
125
+ result = Simple::SQL.all(scope)
126
+ expect(result.length).to eq(0)
127
+
128
+ scope = Postjob::Queue.search("initial" => [ "yay", "nay" ], "multi" => ["nay", "manyay"])
129
+ result = Simple::SQL.all(scope)
130
+ expect(result.length).to eq(1)
131
+ end
106
132
  end
107
133
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: postjob
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.3
4
+ version: 0.4.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - radiospiel
@@ -123,7 +123,7 @@ dependencies:
123
123
  version: '0.4'
124
124
  - - ">="
125
125
  - !ruby/object:Gem::Version
126
- version: 0.4.5
126
+ version: 0.4.7
127
127
  type: :runtime
128
128
  prerelease: false
129
129
  version_requirements: !ruby/object:Gem::Requirement
@@ -133,7 +133,7 @@ dependencies:
133
133
  version: '0.4'
134
134
  - - ">="
135
135
  - !ruby/object:Gem::Version
136
- version: 0.4.5
136
+ version: 0.4.7
137
137
  - !ruby/object:Gem::Dependency
138
138
  name: simple-cli
139
139
  requirement: !ruby/object:Gem::Requirement