talentbox-delayed_job_sequel 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -120,7 +120,15 @@ module Delayed
120
120
 
121
121
  def self.count(attrs={})
122
122
  if attrs.respond_to?(:has_key?) && attrs.has_key?(:conditions)
123
- self.where(attrs[:conditions]).count
123
+ ds = self.where(attrs[:conditions])
124
+ if attrs.has_key?(:group)
125
+ column = attrs[:group]
126
+ group_and_count(column.to_sym).map do |record|
127
+ [column, record[:count]]
128
+ end
129
+ else
130
+ ds.count
131
+ end
124
132
  else
125
133
  super()
126
134
  end
@@ -9,11 +9,20 @@ describe Delayed::Backend::Sequel::Job do
9
9
  it_should_behave_like "a delayed_job backend"
10
10
 
11
11
  context ".count" do
12
- it "allow using ActiveRecord like count for NewRelic sampler" do
13
- expect do
14
- Delayed::Job.count(:conditions => "failed_at is not NULL")
15
- Delayed::Job.count(:conditions => "locked_by is not NULL")
16
- end.to_not raise_error
12
+ context "NewRelic sampler compat" do
13
+ it "allow count with conditions" do
14
+ expect do
15
+ Delayed::Job.count(:conditions => "failed_at is not NULL").should == 1
16
+ Delayed::Job.count(:conditions => "locked_by is not NULL").should == 0
17
+ end.to_not raise_error
18
+ end
19
+
20
+ it "allow count with group and conditions" do
21
+ expect do
22
+ Delayed::Job.count(:group => "queue", :conditions => ['run_at < ? and failed_at is NULL', Time.now]).should =~ [["queue", 1]]
23
+ Delayed::Job.count(:group => "priority", :conditions => ['run_at < ? and failed_at is NULL', Time.now]).should =~ [["priority", 1]]
24
+ end.to_not raise_error
25
+ end
17
26
  end
18
27
  end
19
28
 
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: talentbox-delayed_job_sequel
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.1.1
5
+ version: 0.1.2
6
6
  platform: ruby
7
7
  authors:
8
8
  - Jonathan Tron
@@ -126,7 +126,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
126
126
  version: '0'
127
127
  segments:
128
128
  - 0
129
- hash: 906385450237190959
129
+ hash: 1583338294778399051
130
130
  none: false
131
131
  required_rubygems_version: !ruby/object:Gem::Requirement
132
132
  requirements:
@@ -135,7 +135,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
135
135
  version: '0'
136
136
  segments:
137
137
  - 0
138
- hash: 906385450237190959
138
+ hash: 1583338294778399051
139
139
  none: false
140
140
  requirements: []
141
141
  rubyforge_project: