Commit 810b711436cd5069f5a167ee860208c312b0071c
1 parent
b4aa8e60
Exists in
master
and in
1 other branch
update test to count invalid appearances
Showing
2 changed files
with
7 additions
and
1 deletions
Show diff stats
app/models/appearance.rb
@@ -9,4 +9,10 @@ class Appearance < ActiveRecord::Base | @@ -9,4 +9,10 @@ class Appearance < ActiveRecord::Base | ||
9 | def answered? | 9 | def answered? |
10 | !self.answerable_id.nil? | 10 | !self.answerable_id.nil? |
11 | end | 11 | end |
12 | + | ||
13 | + def self.count_with_exclusive_scope(*args) | ||
14 | + with_exclusive_scope() do | ||
15 | + count(*args) | ||
16 | + end | ||
17 | + end | ||
12 | end | 18 | end |
lib/tasks/test_api.rake
@@ -381,7 +381,7 @@ namespace :test_api do | @@ -381,7 +381,7 @@ namespace :test_api do | ||
381 | 381 | ||
382 | question.expire_prompt_cache_tracking_keys(yesterday) | 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 | if misses + hits != yesterday_appearances | 386 | if misses + hits != yesterday_appearances |
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" | 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" |