Last active
December 22, 2015 16:18
-
-
Save airspeed/6498004 to your computer and use it in GitHub Desktop.
Bearbeitungszeiten Bücher August 2013
This file contains 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
def bearbeitungszeiten(monat = Date.today.month, location = Tempfile.new('Bearbeitungszeiten')) | |
monat = monat.to_i | |
ois = OrderItem.where(:created_at => Date.parse("2013-#{monat}-01")..Date.parse("2013-#{monat + 1}-01")) | |
CSV.open(location, "w", {:col_sep => ";"}) do |csv| | |
ois.each do |oi| | |
t0 = OrderItemStateTransition.where(:order_item_id => oi.id, :to => 'new').first.created_at.to_date | |
delivered = OrderItemStateTransition.where(:order_item_id => oi.id, :to => 'to_delivery').last | |
delivered.nil? ? t1 = Date.today : t1 = delivered.created_at.to_date | |
csv << [oi.code, t0.to_s, t1.to_s, (t1 - t0).to_i.to_s] | |
end | |
end | |
puts "Neuen Tab aufmachen (Ctrl + Shift + t), dann folgenden Befehl reinkopieren:" | |
puts "scp [email protected]:#{location.path} ." | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment