Created
April 18, 2017 12:00
-
-
Save defp/86f1b5ac11b4e0c992052c270e1e4d1d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'csv' | |
headers = [:id, :user_id, :game_profile_internal_key, | |
:total_price, :provider, :game_server_id, :nickname, :created_at] | |
CSV.open('data.csv', 'w', write_headers: true, headers: headers) do |csv| | |
Order.where(status: Order.statuses['shipped']).find_each(batch_size: 2000) do |o| | |
puts o.id | |
csv << [o.id, o.user_id, o.game_profile_internal_key, o.total_price, o.provider, o.game_server_id, o.game_profile.try(:nickname), o.created_at] | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment