Commit 2093d6f20eaf508213c55af20b09bb681c0515c8

Authored by Dhruv Kapadia
1 parent 66785cf6

Limiting prompt_cache hit rate to only run when more than 5 appearances

Showing 1 changed file with 6 additions and 4 deletions   Show diff stats
lib/tasks/test_api.rake
... ... @@ -501,11 +501,13 @@ namespace :test_api do
501 501 if misses + hits != yesterday_appearances
502 502 error_message += "Error! Question #{question.id} isn't tracking prompt cache hits and misses accurately! Expected #{yesterday_appearances}, Actual: #{misses+hits}\n"
503 503 end
504   -
505   - miss_rate = misses.to_f / yesterday_appearances.to_f
506   - if miss_rate > 0.1
  504 +
  505 + if yesterday_appearances > 5 # this test isn't worthwhile for small numbers of appearances
  506 + miss_rate = misses.to_f / yesterday_appearances.to_f
  507 + if miss_rate > 0.1
507 508 error_message += "Error! Question #{question.id} has less than 90% of appearances taken from a pre-generated cache! Expected <#{0.1}, Actual: #{miss_rate}, total appearances yesterday: #{yesterday_appearances}\n"
508   - end
  509 + end
  510 + end
509 511 return error_message.blank? ? [success_message, false] : [error_message, true]
510 512 end
511 513  
... ...