check whether redis is enabled before clearing channel

This commit is contained in:
Lee Lawlor 2014-03-31 23:48:14 -04:00
parent 095daf5abe
commit 47ba7a6fa5
2 changed files with 6 additions and 2 deletions

View File

@ -347,14 +347,15 @@ class Channel < ActiveRecord::Base
end
def delete_feeds
if self.feeds.count < 1000
# if a small number of feeds or redis is not present
if self.feeds.count < 1000 || REDIS_ENABLED == false
Feed.delete_all(["channel_id = ?", self.id])
DailyFeed.delete_all(["channel_id = ?", self.id])
begin
self.update_attribute(:last_entry_id, nil)
rescue Exception => e
end
# else delete via background resque job
else
self.update_attribute(:clearing, true)
Resque.enqueue(ClearChannelJob, self.id)

View File

@ -17,6 +17,9 @@ API_DOMAIN = 'http://127.0.0.1:3000/'
# get api key from HTTP headers if this value is present
HTTP_HEADER_API_KEY_NAME = 'THINGSPEAKAPIKEY'
# whether to use Redis or not
REDIS_ENABLED = false
# Twitter api credentials
CONSUMER_KEY = ''
CONSUMER_SECRET = ''