Skip to content

Instantly share code, notes, and snippets.

@benmullin333
Created May 1, 2014 19:43
Show Gist options
  • Save benmullin333/53c008869e64ac805484 to your computer and use it in GitHub Desktop.
Save benmullin333/53c008869e64ac805484 to your computer and use it in GitHub Desktop.
CSV.foreach("/home/deploy/all_failed_association_tries.csv") do |row|
request = JSON.try(:parse, row.first).inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
product = Product.all.detect{ |p| p.game_id == request[:game_id].to_i && p.client_id == request[:client_id].to_i}
user = User.find_by_id(request[:user_id].to_i)
Ztrack.with_info(:request_product => product, :request_user => user) { Ztrack.associate(request) } unless user && product
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment