order2cb 0.0.7 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/order2cb/order.rb +2 -1
- data/lib/order2cb/version.rb +1 -1
- data/lib/order2cb.rb +7 -3
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4e2229ef56ffe3dffcc8bb7571eeecdeec190a73
|
4
|
+
data.tar.gz: f0186b07add7bfd68d170960568028398caa68ea
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c21d5fe89634a66f7e7a16cd88fc3e9709d12c391953dc45c8febbad269a813f3da92793637d45fceee0577fce5efb8a09f379c04357b829a1a8b9469d23dfe2
|
7
|
+
data.tar.gz: 238176c656f5d32f6da34f4139f47b8456934296f0d7c2d9c3b5431d7411f8c902b9f32011f4252716fd1e39aafa3152525b590f578ec4b7ea6fce43c8dee98b
|
data/lib/order2cb/order.rb
CHANGED
@@ -84,7 +84,8 @@ module Order2cb
|
|
84
84
|
end
|
85
85
|
|
86
86
|
def short_codes
|
87
|
-
@data["
|
87
|
+
sql = "SELECT short_code FROM exp_remote_line_items where order_id = #{@data["id"]};"
|
88
|
+
$db_client.query(sql).map{|row| row["short_code"].to_s.upcase.split("-")}.flatten.compact.uniq
|
88
89
|
end
|
89
90
|
|
90
91
|
def fitting_centre
|
data/lib/order2cb/version.rb
CHANGED
data/lib/order2cb.rb
CHANGED
@@ -50,7 +50,7 @@ module Order2cb
|
|
50
50
|
@logger.info "Starting processing orders from tyreshopper to caseblocks"
|
51
51
|
until @stop
|
52
52
|
begin
|
53
|
-
|
53
|
+
setup_db_client
|
54
54
|
process_orders(all_recent_orders)
|
55
55
|
$db_client.close
|
56
56
|
@logger.debug "Waiting for #{@interval} seconds..."
|
@@ -73,6 +73,10 @@ module Order2cb
|
|
73
73
|
@stop = true
|
74
74
|
end
|
75
75
|
|
76
|
+
def setup_db_client
|
77
|
+
$db_client = Mysql2::Client.new(:host => @tyreshopperDatabaseHost, :username => @tyreshopperDatabaseUser, :password => @tyreshopperDatabasePassword, :database => @tyreshopperDatabaseName)
|
78
|
+
end
|
79
|
+
|
76
80
|
def process_orders(orders_to_process)
|
77
81
|
@logger.debug "Checking for orders"
|
78
82
|
caseblocks = Caseblocks.new(@logger)
|
@@ -80,14 +84,14 @@ module Order2cb
|
|
80
84
|
begin
|
81
85
|
order = ::Order2cb::Order.find(order_number)
|
82
86
|
unless caseblocks.order_exists?(order)
|
83
|
-
@logger.debug "#{order.number} doesn't exist in caseblocks, sending it now"
|
87
|
+
# @logger.debug "#{order.number} doesn't exist in caseblocks, sending it now"
|
84
88
|
if caseblocks.create_order(order)
|
85
89
|
@logger.info "Sent #{order.number} to caseblocks."
|
86
90
|
else
|
87
91
|
@logger.error "Failed to send #{order.number} to caseblocks."
|
88
92
|
end
|
89
93
|
else
|
90
|
-
@logger.debug "#{order.number} already exists in caseblocks... skipping."
|
94
|
+
# @logger.debug "#{order.number} already exists in caseblocks... skipping."
|
91
95
|
end
|
92
96
|
rescue => e
|
93
97
|
@logger.error e.message
|