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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1e2c5038c4f0f9ee2cc0f5c8a97a99c1d41800d2
4
- data.tar.gz: 1affe00b1ec5ece28a35433fd60550e0e4d13782
3
+ metadata.gz: 4e2229ef56ffe3dffcc8bb7571eeecdeec190a73
4
+ data.tar.gz: f0186b07add7bfd68d170960568028398caa68ea
5
5
  SHA512:
6
- metadata.gz: dae875b8bcdd8febfd4a7e3c54fdf2965ed170664cd64f9ecde65bf67cd64ea7d724bb40ccd70b696ab0d7d132e99dc377acbead818545f100222f54327e63e7
7
- data.tar.gz: a13f50736bd1b88a7b76e2c668a2743825ea4b005dd4cffc64306491a01d937be9710353ef438f844cc3a0e42dc09205a6e82bcbe5d2891f1668d3b3ec29939e
6
+ metadata.gz: c21d5fe89634a66f7e7a16cd88fc3e9709d12c391953dc45c8febbad269a813f3da92793637d45fceee0577fce5efb8a09f379c04357b829a1a8b9469d23dfe2
7
+ data.tar.gz: 238176c656f5d32f6da34f4139f47b8456934296f0d7c2d9c3b5431d7411f8c902b9f32011f4252716fd1e39aafa3152525b590f578ec4b7ea6fce43c8dee98b
@@ -84,7 +84,8 @@ module Order2cb
84
84
  end
85
85
 
86
86
  def short_codes
87
- @data["short_code"].to_s.upcase.split("-")
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
@@ -1,3 +1,3 @@
1
1
  module Order2cb
2
- VERSION = "0.0.7"
2
+ VERSION = "0.0.8"
3
3
  end
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
- $db_client = Mysql2::Client.new(:host => @tyreshopperDatabaseHost, :username => @tyreshopperDatabaseUser, :password => @tyreshopperDatabasePassword, :database => @tyreshopperDatabaseName)
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: order2cb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - EmergeAdapt