Skip to content

Instantly share code, notes, and snippets.

@patrick478
Created November 3, 2014 20:47
Show Gist options
  • Save patrick478/6cd7a8aa696e775785cf to your computer and use it in GitHub Desktop.
Save patrick478/6cd7a8aa696e775785cf to your computer and use it in GitHub Desktop.
def publish!
self.posted_at = Time.now
save!
if($redis.get("last_tweet_time") != nil)
last_tweet_time = Time.parse($redis.get("last_tweet_time"))
if((last_tweet_time + 1.hour) > Time.now)
schedule_time = last_tweet_time + 1.hour
puts "Delaying to" + schedule_time.to_s
else
schedule_time = Time.now
end
else
schedule_time = Time.now
end
$redis.set("last_tweet_time", schedule_time.asctime)
Resque.enqueue_at(schedule_time, TweetNewsItem, self.id) if Rails.env.development?
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment