Skip to content

Instantly share code, notes, and snippets.

@pyrat
Created November 10, 2017 09:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pyrat/9fb1b3fa6ca10ee85938a3f45a2317bc to your computer and use it in GitHub Desktop.
Save pyrat/9fb1b3fa6ca10ee85938a3f45a2317bc to your computer and use it in GitHub Desktop.
Stats backdating script
HLRRequest.in_batches.each_with_index do |hlr_reqs, batch_index|
puts "Processing #{batch_index}"
to_delete = []
prev = 0
hlr_reqs.each do |req|
if prev != 0 && prev.msisdn == req.msisdn && notMuchTime(prev, req)
to_delete.push req.id
end
prev = req
end
puts "Removing rows #{to_delete.inspect}"
HLRRequest.delete(to_delete)
end
def notMuchTime(prev, req)
req.created_at - prev.created_at < 2
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment