Commit 810b711436cd5069f5a167ee860208c312b0071c

Authored by Luke Baker
1 parent b4aa8e60

update test to count invalid appearances

app/models/appearance.rb
... ... @@ -9,4 +9,10 @@ class Appearance < ActiveRecord::Base
9 9 def answered?
10 10 !self.answerable_id.nil?
11 11 end
  12 +
  13 + def self.count_with_exclusive_scope(*args)
  14 + with_exclusive_scope() do
  15 + count(*args)
  16 + end
  17 + end
12 18 end
... ...
lib/tasks/test_api.rake
... ... @@ -381,7 +381,7 @@ namespace :test_api do
381 381  
382 382 question.expire_prompt_cache_tracking_keys(yesterday)
383 383  
384   - yesterday_appearances = question.appearances.count(:conditions => ['created_at >= ? AND created_at < ?', Time.now.utc.yesterday.midnight, Time.now.utc.midnight])
  384 + yesterday_appearances = Appearance.count_with_exclusive_scope(:conditions => ['created_at >= ? AND created_at < ? AND question_id = ?', Time.now.utc.yesterday.midnight, Time.now.utc.midnight, question.id])
385 385  
386 386 if misses + hits != yesterday_appearances
387 387 error_message += "Error! Question #{question.id} isn't tracking prompt cache hits and misses accurately! Expected #{yesterday_appearances}, Actual: #{misses+hits}, Hits: #{hits}, Misses: #{misses}\n"
... ...