rawgento_db 0.2.3 → 0.2.4

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: f126b9d037e291509e4e149fece44f4450506a45
4
- data.tar.gz: 9d9d1272743d6deb392f9ff2784990f3879ae866
3
+ metadata.gz: a17786844559ddc64883e7f4f9f5e03bd8da4f7c
4
+ data.tar.gz: 86953338a4ee2fee2305e797f8fe189e2a105636
5
5
  SHA512:
6
- metadata.gz: b8fe8be150648f8900d6b041ce507f9087e4870a8a90cb148b0b51b4aa88a773b83ea3ed44bed46ab33ba272953e5095a48114bda940134bc82f6c7872de3cae
7
- data.tar.gz: 2e7fa8cc0e1bfffb0b34b1fa86702704f9d867f3c475327785eda8390bfbec9c2b95245f42a0f15f2c8897befcc20185c2329227f662f11b732f26d7a8108795
6
+ metadata.gz: f32172387b5f072a38f40684eece3656cf199885bdd54c8366d749993b14e72bec0013b29d388ce81cbd5b3a180602eac5e36c7c2f7bc81997cd2489c2f3328f
7
+ data.tar.gz: 9663c1b3b0f64d72962a2251653a2f11326168e1562dfd98d81fa84558d8d1c791752c5d5e77190d5d5d31c1008fa4209e1f7ecbf343c4aac1a7634bbc690f20
data/README.md CHANGED
@@ -33,6 +33,8 @@ The first 5 keys define access to the mysql (magento) database.
33
33
 
34
34
  ## Usage
35
35
 
36
+ Note that **RawgentoDB does not make any effort to sanitize your input**, which means that crazy and dangerous things can be made with it.
37
+
36
38
  `RawgentoDB` defines the following methods:
37
39
 
38
40
  - `RawgetoDB.settings`: Reads the aforementioned config file and returns its values (a hash). The settings are needed for all the other operations.
@@ -39,16 +39,20 @@ module RawgentoDB
39
39
  end
40
40
 
41
41
  def self.update_stock product_id, stock_addition, settings=RawgentoDB.settings
42
+ if stock_addition.to_i == 0
43
+ return
44
+ end
42
45
  results = client(settings).query(
43
46
  "UPDATE cataloginventory_stock_item SET qty = qty + %f "\
44
47
  "WHERE product_id = %d" % [stock_addition, product_id])
45
48
  end
46
49
 
50
+ # One-way ticket: Do set available if qty > 0 (but not unavailable if <= 0).
47
51
  def self.set_available_on_stock product_id, settings=RawgentoDB.settings
48
52
  result = client(settings).query(
49
53
  "SELECT is_in_stock FROM cataloginventory_stock_item "\
50
54
  "WHERE product_id = %d AND is_in_stock = 0 AND qty > 0" % product_id)
51
- if result.length && result[0] == 0
55
+ if result && result.size > 0 && result[0] == 0
52
56
  result = client(settings).query(
53
57
  "UPDATE cataloginventory_stock_item SET is_in_stock = 1 "\
54
58
  "WHERE product_id = %d" % product_id)
@@ -1,3 +1,3 @@
1
1
  module RawgentoDB
2
- VERSION = "0.2.3"
2
+ VERSION = "0.2.4"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rawgento_db
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Felix Wolfsteller
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-08-12 00:00:00.000000000 Z
11
+ date: 2016-08-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rawgento_models