Commit f4603c148b68cfea737442a2721f411ba4f94e03
1 parent
acebb3ea
Exists in
master
and in
1 other branch
Adding explanation for missing response time in votes, updating test_api
Showing
2 changed files
with
37 additions
and
1 deletions
Show diff stats
db/migrate/20100517153944_add_missing_response_time_exp_to_votes.rb
0 → 100644
| @@ -0,0 +1,22 @@ | @@ -0,0 +1,22 @@ | ||
| 1 | +class AddMissingResponseTimeExpToVotes < ActiveRecord::Migration | ||
| 2 | + def self.up | ||
| 3 | + add_column :votes, :missing_response_time_exp, :string, :default => "" | ||
| 4 | + add_column :skips, :missing_response_time_exp, :string, :default => "" | ||
| 5 | + | ||
| 6 | + recording_client_time_start_date = Vote.find(:all, :conditions => 'time_viewed IS NOT NULL', :order => 'created_at', :limit => 1).first.created_at | ||
| 7 | + Vote.find_each do |v| | ||
| 8 | + if v.created_at <= recording_client_time_start_date && v.time_viewed.nil? | ||
| 9 | + v.missing_response_time_exp = "missing" | ||
| 10 | + v.save! | ||
| 11 | + elsif v.time_viewed.nil? | ||
| 12 | + v.missing_response_time_exp = "invalid" | ||
| 13 | + v.save! | ||
| 14 | + end | ||
| 15 | + end | ||
| 16 | + end | ||
| 17 | + | ||
| 18 | + def self.down | ||
| 19 | + remove_column :votes, :missing_response_time_exp | ||
| 20 | + remove_column :skips, :missing_response_time_exp | ||
| 21 | + end | ||
| 22 | +end |
lib/tasks/test_api.rake
| @@ -218,6 +218,7 @@ namespace :test_api do | @@ -218,6 +218,7 @@ namespace :test_api do | ||
| 218 | error_msg = "" | 218 | error_msg = "" |
| 219 | 219 | ||
| 220 | bad_choices = [] | 220 | bad_choices = [] |
| 221 | + bad_votes = [] | ||
| 221 | questions.each do |question| | 222 | questions.each do |question| |
| 222 | 223 | ||
| 223 | total_wins =0 | 224 | total_wins =0 |
| @@ -386,6 +387,12 @@ namespace :test_api do | @@ -386,6 +387,12 @@ namespace :test_api do | ||
| 386 | error_msg += "Error! There are #{votes_without_appearances} votes without associated appearance objects." | 387 | error_msg += "Error! There are #{votes_without_appearances} votes without associated appearance objects." |
| 387 | end | 388 | end |
| 388 | 389 | ||
| 390 | + skips_without_appearances= Skip.count(:conditions => {:appearance_id => nil}) | ||
| 391 | + if (skips_without_appearances > 0) | ||
| 392 | + error_msg += "Error! There are #{skips_without_appearances} skips without associated appearance objects." | ||
| 393 | + end | ||
| 394 | + | ||
| 395 | + | ||
| 389 | recording_client_time_start_date = Vote.find(:all, :conditions => 'time_viewed IS NOT NULL', :order => 'created_at', :limit => 1).first.created_at | 396 | recording_client_time_start_date = Vote.find(:all, :conditions => 'time_viewed IS NOT NULL', :order => 'created_at', :limit => 1).first.created_at |
| 390 | 397 | ||
| 391 | Vote.find_each(:batch_size => 1000, :include => :appearance) do |v| | 398 | Vote.find_each(:batch_size => 1000, :include => :appearance) do |v| |
| @@ -409,8 +416,10 @@ namespace :test_api do | @@ -409,8 +416,10 @@ namespace :test_api do | ||
| 409 | error_msg += the_error_msg | 416 | error_msg += the_error_msg |
| 410 | print the_error_msg | 417 | print the_error_msg |
| 411 | 418 | ||
| 419 | + bad_votes << v.id | ||
| 420 | + | ||
| 412 | elsif v.time_viewed.nil? | 421 | elsif v.time_viewed.nil? |
| 413 | - if v.created_at > recording_client_time_start_date | 422 | + if v.created_at > recording_client_time_start_date && v.missing_response_time_exp != 'invalid' |
| 414 | the_error_msg = "Error! Vote #{v.id} with Appearance #{v.appearance.id}, does not have a client response, even though it should! Vote creation time: #{v.created_at.to_s}, Appearance creation time: #{v.appearance.created_at.to_s}, Client side response time: #{v.time_viewed}\n" | 423 | the_error_msg = "Error! Vote #{v.id} with Appearance #{v.appearance.id}, does not have a client response, even though it should! Vote creation time: #{v.created_at.to_s}, Appearance creation time: #{v.appearance.created_at.to_s}, Client side response time: #{v.time_viewed}\n" |
| 415 | error_msg += the_error_msg | 424 | error_msg += the_error_msg |
| 416 | print the_error_msg | 425 | print the_error_msg |
| @@ -454,6 +463,11 @@ namespace :test_api do | @@ -454,6 +463,11 @@ namespace :test_api do | ||
| 454 | puts "Here's a list of choice ids that you may want to modify: #{bad_choices.uniq.inspect}" | 463 | puts "Here's a list of choice ids that you may want to modify: #{bad_choices.uniq.inspect}" |
| 455 | 464 | ||
| 456 | end | 465 | end |
| 466 | + unless bad_votes.blank? | ||
| 467 | + | ||
| 468 | + puts "Here's a list of vote ids that you may want to modify: #{bad_votes.uniq.inspect}" | ||
| 469 | + | ||
| 470 | + end | ||
| 457 | print error_msg | 471 | print error_msg |
| 458 | end | 472 | end |
| 459 | 473 |