Skip to content

Commit

Permalink
Remove not used variable and whitespaces
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosantoniodasilva committed Mar 20, 2012
1 parent d9e7198 commit 01d0862
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 28 deletions.
13 changes: 6 additions & 7 deletions lib/resque/scheduler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class << self

# If set, will try to update the schulde in the loop
attr_accessor :dynamic

# Amount of time in seconds to sleep between polls of the delayed
# queue. Defaults to 5
attr_writer :poll_sleep_amount
Expand All @@ -26,7 +26,7 @@ class << self
def scheduled_jobs
@@scheduled_jobs
end

def poll_sleep_amount
@poll_sleep_amount ||= 5 # seconds
end
Expand Down Expand Up @@ -75,7 +75,7 @@ def register_signal_handlers
end
end

def print_schedule
def print_schedule
if rufus_scheduler
log! "Scheduling Info\tLast Run"
scheduler_jobs = rufus_scheduler.all_jobs
Expand All @@ -89,7 +89,7 @@ def print_schedule
# rufus scheduler instance
def load_schedule!
procline "Loading Schedule"

# Need to load the schedule from redis for the first time if dynamic
Resque.reload_schedule! if dynamic

Expand All @@ -103,7 +103,7 @@ def load_schedule!
Resque.redis.del(:schedules_changed)
procline "Schedules Loaded"
end

# modify interval type value to value with options if options available
def optionizate_interval_value(value)
args = value
Expand Down Expand Up @@ -155,7 +155,6 @@ def rails_env_matches?(config)
# Handles queueing delayed items
# at_time - Time to start scheduling items (default: now).
def handle_delayed_items(at_time=nil)
item = nil
if timestamp = Resque.next_delayed_timestamp(at_time)
procline "Processing Delayed Items"
while !timestamp.nil?
Expand Down Expand Up @@ -184,7 +183,7 @@ def handle_shutdown
yield
exit if @shutdown
end

def handle_errors
begin
yield
Expand Down
32 changes: 16 additions & 16 deletions lib/resque_scheduler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,12 @@ def schedule=(schedule_hash)
def schedule
@schedule ||= {}
end

# reloads the schedule from redis
def reload_schedule!
@schedule = get_schedules
end

# gets the schedule as it exists in redis
def get_schedules
if redis.exists(:schedules)
Expand All @@ -77,12 +77,12 @@ def get_schedules
nil
end
end

# Create or update a schedule with the provided name and configuration.
#
# Note: values for class and custom_job_class need to be strings,
# not constants.
#
#
# Resque.set_schedule('some_job', {:class => 'SomeJob',
# :every => '15mins',
# :queue => 'high',
Expand All @@ -95,12 +95,12 @@ def set_schedule(name, config)
end
config
end

# retrive the schedule configuration for the given name
def get_schedule(name)
decode(redis.hget(:schedules, name))
end

# remove a given schedule by name
def remove_schedule(name)
redis.hdel(:schedules, name)
Expand All @@ -117,13 +117,13 @@ def enqueue_at(timestamp, klass, *args)
end

# Identical to +enqueue_at+, except you can also specify
# a queue in which the job will be placed after the
# a queue in which the job will be placed after the
# timestamp has passed.
def enqueue_at_with_queue(queue, timestamp, klass, *args)
return false unless Plugin.run_before_schedule_hooks(klass, *args)

delayed_push(timestamp, job_to_hash_with_queue(queue, klass, args))

Plugin.run_after_schedule_hooks(klass, *args)
end

Expand All @@ -134,7 +134,7 @@ def enqueue_in(number_of_seconds_from_now, klass, *args)
end

# Identical to +enqueue_in+, except you can also specify
# a queue in which the job will be placed after the
# a queue in which the job will be placed after the
# number of seconds has passed.
def enqueue_in_with_queue(queue, number_of_seconds_from_now, klass, *args)
enqueue_at_with_queue(queue, Time.now + number_of_seconds_from_now, klass, *args)
Expand Down Expand Up @@ -210,7 +210,7 @@ def reset_delayed_queue
end

# Given an encoded item, remove it from the delayed_queue
#
#
# This method is potentially very expensive since it needs to scan
# through the delayed queue for every timestamp.
def remove_delayed(klass, *args)
Expand All @@ -221,7 +221,7 @@ def remove_delayed(klass, *args)
end
destroyed
end

# Given a timestamp and job (klass + args) it removes all instances and
# returns the count of jobs removed.
#
Expand All @@ -238,16 +238,16 @@ def count_all_scheduled_jobs
total_jobs = 0
Array(redis.zrange(:delayed_queue_schedule, 0, -1)).each do |timestamp|
total_jobs += redis.llen("delayed:#{timestamp}").to_i
end
end
total_jobs
end
end

private

def job_to_hash(klass, args)
{:class => klass.to_s, :args => args, :queue => queue_from_class(klass)}
end

def job_to_hash_with_queue(queue, klass, args)
{:class => klass.to_s, :args => args, :queue => queue}
end
Expand Down
10 changes: 5 additions & 5 deletions lib/resque_scheduler/server.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

# Extend Resque::Server to add tabs
module ResqueScheduler

module Server

def self.included(base)
Expand Down Expand Up @@ -29,7 +29,7 @@ def queue_from_class_name(class_name)
Resque::Scheduler.enqueue_from_config(config)
redirect u("/overview")
end

get "/delayed" do
# Is there a better way to specify alternate template locations with sinatra?
erb File.read(File.join(File.dirname(__FILE__), 'server/views/delayed.erb'))
Expand All @@ -39,13 +39,13 @@ def queue_from_class_name(class_name)
# Is there a better way to specify alternate template locations with sinatra?
erb File.read(File.join(File.dirname(__FILE__), 'server/views/delayed_timestamp.erb'))
end

post "/delayed/queue_now" do
timestamp = params['timestamp']
Resque::Scheduler.enqueue_delayed_items_for_timestamp(timestamp.to_i) if timestamp.to_i > 0
redirect u("/overview")
end

post "/delayed/clear" do
Resque.reset_delayed_queue
redirect u('delayed')
Expand All @@ -59,5 +59,5 @@ def queue_from_class_name(class_name)
Resque::Server.tabs << 'Delayed'

end

end

0 comments on commit 01d0862

Please sign in to comment.