check whether redis is enabled before clearing channel
This commit is contained in:
parent
095daf5abe
commit
47ba7a6fa5
@ -347,14 +347,15 @@ class Channel < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
|
|
||||||
def delete_feeds
|
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])
|
Feed.delete_all(["channel_id = ?", self.id])
|
||||||
DailyFeed.delete_all(["channel_id = ?", self.id])
|
DailyFeed.delete_all(["channel_id = ?", self.id])
|
||||||
begin
|
begin
|
||||||
self.update_attribute(:last_entry_id, nil)
|
self.update_attribute(:last_entry_id, nil)
|
||||||
rescue Exception => e
|
rescue Exception => e
|
||||||
end
|
end
|
||||||
|
# else delete via background resque job
|
||||||
else
|
else
|
||||||
self.update_attribute(:clearing, true)
|
self.update_attribute(:clearing, true)
|
||||||
Resque.enqueue(ClearChannelJob, self.id)
|
Resque.enqueue(ClearChannelJob, self.id)
|
||||||
|
@ -17,6 +17,9 @@ API_DOMAIN = 'http://127.0.0.1:3000/'
|
|||||||
# get api key from HTTP headers if this value is present
|
# get api key from HTTP headers if this value is present
|
||||||
HTTP_HEADER_API_KEY_NAME = 'THINGSPEAKAPIKEY'
|
HTTP_HEADER_API_KEY_NAME = 'THINGSPEAKAPIKEY'
|
||||||
|
|
||||||
|
# whether to use Redis or not
|
||||||
|
REDIS_ENABLED = false
|
||||||
|
|
||||||
# Twitter api credentials
|
# Twitter api credentials
|
||||||
CONSUMER_KEY = ''
|
CONSUMER_KEY = ''
|
||||||
CONSUMER_SECRET = ''
|
CONSUMER_SECRET = ''
|
||||||
|
Loading…
Reference in New Issue
Block a user