diff --git a/app/models/choice.rb b/app/models/choice.rb index 71d419b..12bd0af 100644 --- a/app/models/choice.rb +++ b/app/models/choice.rb @@ -117,7 +117,7 @@ class Choice < ActiveRecord::Base return if previous_choices.empty? inserts = [] - timestring = Time.now.to_s(:db) #isn't rails awesome? + timestring = Time.now.utc.to_s(:db) #isn't rails awesome? #add prompts with this choice on the left previous_choices.each do |r| diff --git a/app/models/question.rb b/app/models/question.rb index 30d3632..94af834 100644 --- a/app/models/question.rb +++ b/app/models/question.rb @@ -542,11 +542,11 @@ class Question < ActiveRecord::Base end def record_prompt_cache_miss - $redis.incr(self.pq_key + "_" + Time.now.to_date.to_s + "_"+ "misses") + $redis.incr(self.pq_key + "_" + Time.now.utc.to_date.to_s + "_"+ "misses") end def record_prompt_cache_hit - $redis.incr(self.pq_key + "_" + Time.now.to_date.to_s + "_"+ "hits") + $redis.incr(self.pq_key + "_" + Time.now.utc.to_date.to_s + "_"+ "hits") end def get_prompt_cache_misses(date) diff --git a/lib/tasks/test_api.rake b/lib/tasks/test_api.rake index 38894df..47327c4 100644 --- a/lib/tasks/test_api.rake +++ b/lib/tasks/test_api.rake @@ -362,12 +362,13 @@ namespace :test_api do success_message = "At least 90% of prompts on catchup algorithm questions were served from cache\n" return [success_message, false] unless question.uses_catchup? - misses = question.get_prompt_cache_misses(Date.yesterday).to_i - hits = question.get_prompt_cache_hits(Date.yesterday).to_i + yesterday = Time.now.utc.yesterday.to_date + misses = question.get_prompt_cache_misses(yesterday).to_i + hits = question.get_prompt_cache_hits(yesterday).to_i - question.expire_prompt_cache_tracking_keys(Date.yesterday) + question.expire_prompt_cache_tracking_keys(yesterday) - yesterday_appearances = question.appearances.count(:conditions => ['created_at >= ? AND created_at < ?', Time.now.yesterday.midnight.utc, Time.now.midnight.utc]) + yesterday_appearances = question.appearances.count(:conditions => ['created_at >= ? AND created_at < ?', Time.now.utc.yesterday.midnight, Time.now.utc.midnight]) if misses + hits != yesterday_appearances 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" -- libgit2 0.21.2