rawgento_db 0.2.3 → 0.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +2 -0
- data/lib/rawgento_db/query.rb +5 -1
- data/lib/rawgento_db/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a17786844559ddc64883e7f4f9f5e03bd8da4f7c
|
4
|
+
data.tar.gz: 86953338a4ee2fee2305e797f8fe189e2a105636
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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.
|
data/lib/rawgento_db/query.rb
CHANGED
@@ -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.
|
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)
|
data/lib/rawgento_db/version.rb
CHANGED
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.
|
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-
|
11
|
+
date: 2016-08-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rawgento_models
|