Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed rails 2 compatibility #26

Merged
merged 1 commit into from Feb 10, 2013
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
30 changes: 8 additions & 22 deletions lib/delayed/backend/active_record.rb
Expand Up @@ -12,33 +12,19 @@ class Job < ::ActiveRecord::Base

before_save :set_default_run_at

def self.rails3?
::ActiveRecord::VERSION::MAJOR == 3
end

def self.set_delayed_job_table_name
delayed_job_table_name = "#{::ActiveRecord::Base.table_name_prefix}delayed_jobs"

if rails3?
self.table_name = delayed_job_table_name
else
set_table_name delayed_job_table_name
end
self.table_name = delayed_job_table_name
end

self.set_delayed_job_table_name

if rails3?
def self.ready_to_run(worker_name, max_run_time)
where('(run_at <= ? AND (locked_at IS NULL OR locked_at < ?) OR locked_by = ?) AND failed_at IS NULL', db_time_now, db_time_now - max_run_time, worker_name)
end
def self.by_priority
order('priority ASC, run_at ASC')
end
else
named_scope :ready_to_run, lambda {|worker_name, max_run_time|
{ :conditions => ['(run_at <= ? AND (locked_at IS NULL OR locked_at < ?) OR locked_by = ?) AND failed_at IS NULL', db_time_now, db_time_now - max_run_time, worker_name] }
}
named_scope :by_priority, :order => 'priority ASC, run_at ASC'
def self.ready_to_run(worker_name, max_run_time)
where('(run_at <= ? AND (locked_at IS NULL OR locked_at < ?) OR locked_by = ?) AND failed_at IS NULL', db_time_now, db_time_now - max_run_time, worker_name)
end

def self.by_priority
order('priority ASC, run_at ASC')
end

def self.before_fork
Expand Down