Commit acebb3ea149e480e172c1e33bf50800caa8ce1cb
1 parent
fbaef6f3
Exists in
master
and in
1 other branch
Bugfix: accurately count number of catchup hits and misses
Showing
2 changed files
with
10 additions
and
2 deletions
Show diff stats
app/models/question.rb
... | ... | @@ -342,12 +342,10 @@ class Question < ActiveRecord::Base |
342 | 342 | |
343 | 343 | def record_prompt_cache_miss |
344 | 344 | $redis.incr(self.pq_key + "_" + Time.now.to_date.to_s + "_"+ "misses") |
345 | - $redis.expire(self.pq_key, 24*60*60 * 3) #Expire in three days | |
346 | 345 | end |
347 | 346 | |
348 | 347 | def record_prompt_cache_hit |
349 | 348 | $redis.incr(self.pq_key + "_" + Time.now.to_date.to_s + "_"+ "hits") |
350 | - $redis.expire(self.pq_key, 24*60*60 * 3) #Expire in three days | |
351 | 349 | end |
352 | 350 | |
353 | 351 | def get_prompt_cache_misses(date) |
... | ... | @@ -357,6 +355,13 @@ class Question < ActiveRecord::Base |
357 | 355 | $redis.get(self.pq_key + "_" + date.to_s + "_"+ "hits") |
358 | 356 | end |
359 | 357 | |
358 | + | |
359 | + def expire_prompt_cache_tracking_keys(date, expire_time = 24*60*60 * 3) # default expires in three days | |
360 | + $redis.expire(self.pq_key + "_" + date.to_s + "_"+ "hits", expire_time) | |
361 | + $redis.expire(self.pq_key + "_" + date.to_s + "_"+ "misses", expire_time) | |
362 | + end | |
363 | + | |
364 | + | |
360 | 365 | def export_and_delete(type, options={}) |
361 | 366 | delete_at = options.delete(:delete_at) |
362 | 367 | filename = export(type, options) | ... | ... |
lib/tasks/test_api.rake
... | ... | @@ -357,6 +357,9 @@ namespace :test_api do |
357 | 357 | misses = question.get_prompt_cache_misses(Date.yesterday).to_i |
358 | 358 | hits = question.get_prompt_cache_hits(Date.yesterday).to_i |
359 | 359 | |
360 | + question.expire_prompt_cache_tracking_keys(Date.yesterday) | |
361 | + | |
362 | + | |
360 | 363 | |
361 | 364 | yesterday_votes = question.appearances.count(:conditions => ['date(created_at) = ?', Date.yesterday]) |
362 | 365 | ... | ... |