Skip to content

Instantly share code, notes, and snippets.

@criess
Created May 24, 2018 09:57
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 criess/633c4f56701fd4699ce318f038ae519c to your computer and use it in GitHub Desktop.
Save criess/633c4f56701fd4699ce318f038ae519c to your computer and use it in GitHub Desktop.
File.open("selling.csv","w") do |f|
f.write("selling_key;selling_value;order_id;order_date;order_state;order_product\n")
f.write(
ConcernExtensionEntry.where(:value => %w[0 1]).
where("created_at > ?", Date.new(2018,1,31).end_of_day).
where("created_at < ?", Date.new(2018,4,1).beginning_of_day).
where("`key` LIKE ?", "selling_%").
map do |ce|
t = Tenancy.find(ce.target_id)
"#{ce.key};#{ce.value};#{t.id};#{t.updated_at};#{t.state};#{t.product}"
end.
join("\n")
)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment