diff --git a/app/models/question.rb b/app/models/question.rb index 674baa8..66f70b0 100644 --- a/app/models/question.rb +++ b/app/models/question.rb @@ -342,12 +342,10 @@ class Question < ActiveRecord::Base def record_prompt_cache_miss $redis.incr(self.pq_key + "_" + Time.now.to_date.to_s + "_"+ "misses") - $redis.expire(self.pq_key, 24*60*60 * 3) #Expire in three days end def record_prompt_cache_hit $redis.incr(self.pq_key + "_" + Time.now.to_date.to_s + "_"+ "hits") - $redis.expire(self.pq_key, 24*60*60 * 3) #Expire in three days end def get_prompt_cache_misses(date) @@ -357,6 +355,13 @@ class Question < ActiveRecord::Base $redis.get(self.pq_key + "_" + date.to_s + "_"+ "hits") end + + def expire_prompt_cache_tracking_keys(date, expire_time = 24*60*60 * 3) # default expires in three days + $redis.expire(self.pq_key + "_" + date.to_s + "_"+ "hits", expire_time) + $redis.expire(self.pq_key + "_" + date.to_s + "_"+ "misses", expire_time) + end + + def export_and_delete(type, options={}) delete_at = options.delete(:delete_at) filename = export(type, options) diff --git a/lib/tasks/test_api.rake b/lib/tasks/test_api.rake index 38377e2..dfad8b6 100644 --- a/lib/tasks/test_api.rake +++ b/lib/tasks/test_api.rake @@ -357,6 +357,9 @@ namespace :test_api do misses = question.get_prompt_cache_misses(Date.yesterday).to_i hits = question.get_prompt_cache_hits(Date.yesterday).to_i + question.expire_prompt_cache_tracking_keys(Date.yesterday) + + yesterday_votes = question.appearances.count(:conditions => ['date(created_at) = ?', Date.yesterday]) -- libgit2 0.21.2