-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathorder.etl
executable file
·87 lines (77 loc) · 3.75 KB
/
order.etl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#!/usr/bin/env ruby
#require '../config/environment'
$:.unshift "#{File.dirname(__FILE__)}"
require 'order_source'
require 'order_destination'
# postgres://tlvtkosncfcgav:3PU-1SH15kb7a_0G6TZ-BazZgS@ec2-54-83-201-54.compute-1.amazonaws.com:5432/d4f6vsl9eg8nia
#trans_url = 'dbname=d4f6vsl9eg8nia user=tlvtkosncfcgav password=3PU-1SH15kb7a_0G6TZ-BazZgS host=ec2-54-83-201-54.compute-1.amazonaws.com port=5432'
trans_url = ENV['TRANS_DB_URL']
source OrderSource, trans_url
start_time = Time.now
num_rows = 0
pre_process do
puts "*** START ORDER MIGRATION #{start_time}***"
end
transform do |row|
num_rows = num_rows + 1
newrow = {}
newrow[:organization_id] = row[:organization_id]
newrow[:order_id] = row[:order_id]
newrow[:order_item_id] = row[:order_item_id]
newrow[:market] = row[:market]
newrow[:market_city] = row[:market_city]
newrow[:market_state] = row[:market_state]
newrow[:market_zip] = row[:market_zip]
newrow[:market_country] = row[:market_country]
newrow[:placed_on] = row[:placed_on]
newrow[:order_number] = row[:order_number]
newrow[:buyer] = row[:buyer]
newrow[:buyer_city] = row[:buyer_city]
newrow[:buyer_state] = row[:buyer_state]
newrow[:buyer_zip] = row[:buyer_zip]
newrow[:buyer_country] = row[:buyer_country]
newrow[:product] = row[:product]
newrow[:short_description] = row[:short_description]
newrow[:product_code] = row[:product_code]
newrow[:top_level_category] = row[:top_level_category]
newrow[:supplier] = row[:supplier]
newrow[:supplier_city] = row[:supplier_city]
newrow[:supplier_state] = row[:supplier_state]
newrow[:supplier_zip] = row[:supplier_zip]
newrow[:supplier_country] = row[:supplier_country]
newrow[:quantity] = row[:quantity]
newrow[:unit] = row[:unit]
newrow[:unit_description] = row[:unit_description]
newrow[:total_cost] = row[:total_cost]
newrow[:delivery_fees] = row[:delivery_fees]
newrow[:unit_price] = row[:unit_price]
newrow[:gross_price] = row[:gross_price]
newrow[:actual_discount] = row[:actual_discount]
newrow[:net_price] = row[:net_price]
newrow[:delivery_status] = row[:delivery_status]
newrow[:delivery_datetime] = row[:delivery_datetime]
newrow[:shipping_terms] = row[:shipping_terms]
newrow[:delivery_city] = row[:delivery_city]
newrow[:delivery_state] = row[:delivery_state]
newrow[:delivery_zip] = row[:delivery_zip]
newrow[:delivery_country] = row[:delivery_country]
newrow[:buyer_payment_status] = row[:buyer_payment_status]
newrow[:supplier_payment_status] = row[:supplier_payment_status]
newrow[:market_active] = row[:market_active]
newrow[:second_level_category] = row[:second_level_category]
newrow[:supplier_latitude] = row[:supplier_latitude]
newrow[:supplier_longitude] = row[:supplier_longitude]
newrow[:buyer_latitude] = row[:buyer_latitude]
newrow[:buyer_longitude] = row[:buyer_longitude]
newrow
end
post_process do
end_time = Time.now
duration_in_minutes = (end_time - start_time)/60
puts "*** End ORDER MIGRATION #{end_time}***"
puts "*** Duration (min): #{duration_in_minutes.round(2)}"
puts "*** Rows Processed: #{num_rows}"
end
dw_url = ENV['DW_DB_URL']
#dw_url = 'dbname=local_orbit_development_dw user=andyb password=i81u812 host=localhost port=5432'
destination OrderDestination, dw_url