Commit af6a0e28fec8b1d7215edadcfbb8ea8c099aa507
1 parent
35d65cf1
Exists in
master
and in
1 other branch
update response time fixer to accept start id
Showing
1 changed file
with
5 additions
and
15 deletions
Show diff stats
lib/tasks/prune_db.rake
@@ -265,30 +265,20 @@ namespace :prune_db do | @@ -265,30 +265,20 @@ namespace :prune_db do | ||
265 | 265 | ||
266 | 266 | ||
267 | desc "Invalidates votes with bad response times" | 267 | desc "Invalidates votes with bad response times" |
268 | - task :invalidate_votes_with_bad_response_times => :environment do | ||
269 | - badvotes = [] | ||
270 | - #might want to optimize later to not start from the beginning each time | 268 | + task :invalidate_votes_with_bad_response_times, [:start_vote_id] => [:environment] do |t, args| |
269 | + args.with_defaults(:start_vote_id => 0) | ||
271 | STDOUT.sync = true | 270 | STDOUT.sync = true |
272 | - Vote.find_each(:batch_size => 10000, :include => :appearance) do |v| | 271 | + Vote.find_each(:batch_size => 10000, :include => :appearance, :conditions => ["votes.id >= ?", args[:start_vote_id]]) do |v| |
273 | next if v.nil? || v.appearance.nil? | 272 | next if v.nil? || v.appearance.nil? |
274 | server_response_time = v.created_at.to_f - v.appearance.created_at.to_f | 273 | server_response_time = v.created_at.to_f - v.appearance.created_at.to_f |
275 | if v.time_viewed && v.time_viewed/1000 > server_response_time | 274 | if v.time_viewed && v.time_viewed/1000 > server_response_time |
276 | - badvotes << v | ||
277 | - print "." | ||
278 | - end | ||
279 | - end | ||
280 | - puts "\n" | ||
281 | - | ||
282 | - if badvotes.any? | ||
283 | - | ||
284 | - badvotes.each do |v| | ||
285 | v.time_viewed = nil | 275 | v.time_viewed = nil |
286 | v.missing_response_time_exp = "invalid" | 276 | v.missing_response_time_exp = "invalid" |
287 | v.save! | 277 | v.save! |
278 | + print "." | ||
288 | end | 279 | end |
289 | - else | ||
290 | - puts "Could not find any bad votes. Yay." | ||
291 | end | 280 | end |
281 | + print "\n" | ||
292 | end | 282 | end |
293 | 283 | ||
294 | task :associate_skips_with_appearances => :environment do | 284 | task :associate_skips_with_appearances => :environment do |