2014-04-05 20:19:04 +01:00
|
|
|
class CleanApiDefenderStatisticsJob
|
2014-04-15 19:41:06 +01:00
|
|
|
@queue = :low
|
2014-04-05 20:19:04 +01:00
|
|
|
|
|
|
|
def self.perform
|
|
|
|
deadline = Date.today - 1.month
|
|
|
|
Redis.current.keys.select do |key|
|
|
|
|
next if key !~ /^throttle:/
|
|
|
|
# See: https://github.com/datagraph/rack-throttle/blob/master/lib/rack/throttle/daily.rb#L41
|
|
|
|
# Formats:
|
|
|
|
# 'throttle:uname:%Y-%m-%dT%H', 'throttle:uname:%Y-%m-%d'
|
2014-04-05 20:20:44 +01:00
|
|
|
# example: "throttle:uname1:2014-01-25T20", "throttle:uname1:2014-01-25"
|
2014-04-05 20:19:04 +01:00
|
|
|
date = key.gsub(/.*:/, '').gsub(/T.*/, '')
|
|
|
|
Redis.current.del(key) if Date.parse(date) < deadline
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|