Skip to content

Commit

Permalink
Merge pull request #4 from finventures/master
Browse files Browse the repository at this point in the history
  • Loading branch information
jturkel authored Sep 23, 2017
2 parents f402ddc + e92425e commit 649c25a
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 9 deletions.
5 changes: 5 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ env:
- RAILS_VERSION="~> 4.1.16"
- RAILS_VERSION="~> 4.2.9"
- RAILS_VERSION="~> 5.0.6"
- RAILS_VERSION="~> 5.1.3"
rvm:
- 2.1.10
- 2.2.8
Expand All @@ -27,3 +28,7 @@ matrix:
env: RAILS_VERSION="~> 4.1.16"
- rvm: jruby-9.1.13.0
env: RAILS_VERSION="~> 5.0.6"
- rvm: 2.1.10
env: RAILS_VERSION="~> 5.1.3"
- rvm: jruby-9.1.13.0
env: RAILS_VERSION="~> 5.1.3"
2 changes: 1 addition & 1 deletion delayed_job_groups.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Gem::Specification.new do |spec|

spec.post_install_message = 'See https://github.com/salsify/delayed_job_groups_plugin#installation for upgrade/installation notes.'

spec.add_development_dependency 'activerecord', ENV.fetch('RAILS_VERSION', ['>= 3.2', '< 5.1'])
spec.add_development_dependency 'activerecord', ENV.fetch('RAILS_VERSION', ['>= 3.2', '< 5.2'])
spec.add_development_dependency 'coveralls'
spec.add_development_dependency 'database_cleaner', '>= 1.2'
# rspec < 3.5 requires rake < 11.0
Expand Down
13 changes: 6 additions & 7 deletions lib/delayed/job_groups/job_extensions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ module Delayed
module JobGroups
module JobExtensions
extend ActiveSupport::Concern
module ReadyToRunExtension
def ready_to_run(worker_name, max_run_time)
super(worker_name, max_run_time).where(blocked: false)
end
end

included do
if Delayed::JobGroups::Compatibility.mass_assignment_security_enabled?
Expand All @@ -13,15 +18,9 @@ module JobExtensions
belongs_to :job_group, class_name: 'Delayed::JobGroups::JobGroup'

class << self

# Patch ready_to_run to exclude blocked jobs
def ready_to_run_with_blocked_filtering(worker_name, max_run_time)
ready_to_run_without_blocked_filtering(worker_name, max_run_time).where(blocked: false)
end
alias_method_chain :ready_to_run, :blocked_filtering
prepend ReadyToRunExtension
end
end

def in_job_group?
job_group_id.present?
end
Expand Down
2 changes: 1 addition & 1 deletion lib/delayed/job_groups/job_group.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class JobGroup < ActiveRecord::Base
validates :queueing_complete, :blocked, :failure_cancels_group, inclusion: [true, false]

if ActiveRecord::VERSION::MAJOR >= 4
has_many :active_jobs, -> { where(failed_at: nil) }, class_name: Job
has_many :active_jobs, -> { where(failed_at: nil) }, class_name: '::Delayed::Job'
else
has_many :active_jobs, class_name: Job, conditions: {failed_at: nil}
end
Expand Down

0 comments on commit 649c25a

Please sign in to comment.