rawgento_db 0.0.2 → 0.0.3
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 +8 -8
- 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: c83957aeeb965ba0c52cb85ec1050676196a5606
|
4
|
+
data.tar.gz: bde063b48ba8338f06a4c3593032baebf360d25e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 240f5c485cfac378044b2cf7018117ebee914da9ef74ebff079d4500a03568b3742524615e2da3647a35c23d812b2b7dd34b72156764fc7bddbf0def860126aa
|
7
|
+
data.tar.gz: f33df13b5d0dea5b6e7da85082b6bb76243a8bcf613cc235666c032024b09650efe9d74d62dfc99a2d81df4087f9cd97fb7bec082be9a242a62ba04c025cb86d
|
data/README.md
CHANGED
@@ -44,6 +44,8 @@ The first 5 keys define access to the mysql (magento) database.
|
|
44
44
|
- `RawgentoDB::Query.attribute_varchar(attribute_id, settings)`: Returns array of [product_id, attribute_value] varchar-attribute-value information for all products.
|
45
45
|
- `RawgentoDB::Query.attribute_option(attribute_id, settings)`: Returns array of [product_id, attribute_value] attribute-value of an option for all products.
|
46
46
|
|
47
|
+
All of these can optionally be called with a (second) parameter settings, which is the yaml parsed file. To initialize the settings, call `RawgentoDB.settings filename`.
|
48
|
+
|
47
49
|
|
48
50
|
Furthermore, some command line applications are provided to get a view on the Shop through the eyes of the `rawgento_db` gem:
|
49
51
|
|
data/lib/rawgento_db/query.rb
CHANGED
@@ -5,12 +5,12 @@ module RawgentoDB
|
|
5
5
|
ProductQty = Struct.new(:product_id, :qty)
|
6
6
|
|
7
7
|
class Query
|
8
|
-
def self.client settings
|
8
|
+
def self.client settings=RawgentoDB.settings
|
9
9
|
# Pick up a memoized settings?
|
10
10
|
Mysql2::Client.new settings
|
11
11
|
end
|
12
12
|
|
13
|
-
def self.products settings
|
13
|
+
def self.products settings=RawgentoDB.settings
|
14
14
|
# Unfortunately, name is an own attribute in different table.
|
15
15
|
result = client(settings).query('SELECT entity_id '\
|
16
16
|
'FROM catalog_product_entity')
|
@@ -19,7 +19,7 @@ module RawgentoDB
|
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
|
-
def self.stock settings
|
22
|
+
def self.stock settings=RawgentoDB.settings
|
23
23
|
result = client(settings).query('SELECT product_id, qty '\
|
24
24
|
'FROM cataloginventory_stock_item ')
|
25
25
|
result.map do |r|
|
@@ -27,7 +27,7 @@ module RawgentoDB
|
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
30
|
-
def self.understocked settings
|
30
|
+
def self.understocked settings=RawgentoDB.settings
|
31
31
|
results = client(settings).query(
|
32
32
|
"SELECT product_id, qty, notify_stock_qty "\
|
33
33
|
"FROM cataloginventory_stock_item "\
|
@@ -38,7 +38,7 @@ module RawgentoDB
|
|
38
38
|
end
|
39
39
|
end
|
40
40
|
|
41
|
-
def self.sales_monthly product_id, settings
|
41
|
+
def self.sales_monthly product_id, settings=RawgentoDB.settings
|
42
42
|
result = client(settings).query('SELECT * '\
|
43
43
|
'FROM sales_bestsellers_aggregated_monthly '\
|
44
44
|
' WHERE product_id = %d ORDER BY period DESC' % product_id)
|
@@ -47,7 +47,7 @@ module RawgentoDB
|
|
47
47
|
end
|
48
48
|
end
|
49
49
|
|
50
|
-
def self.sales_daily product_id, settings
|
50
|
+
def self.sales_daily product_id, settings=RawgentoDB.settings
|
51
51
|
result = client(settings).query('SELECT * '\
|
52
52
|
'FROM sales_bestsellers_aggregated_daily '\
|
53
53
|
' WHERE product_id = %d ORDER BY period DESC' % product_id)
|
@@ -56,7 +56,7 @@ module RawgentoDB
|
|
56
56
|
end
|
57
57
|
end
|
58
58
|
|
59
|
-
def self.attribute_varchar attribute_id, settings
|
59
|
+
def self.attribute_varchar attribute_id, settings=RawgentoDB.settings
|
60
60
|
result = client(settings).query("
|
61
61
|
SELECT entity_id, value
|
62
62
|
FROM catalog_product_entity_varchar
|
@@ -66,7 +66,7 @@ module RawgentoDB
|
|
66
66
|
end
|
67
67
|
end
|
68
68
|
|
69
|
-
def self.attribute_option attribute_id, settings
|
69
|
+
def self.attribute_option attribute_id, settings=RawgentoDB.settings
|
70
70
|
# Join
|
71
71
|
result = client(settings).query("
|
72
72
|
SELECT optchoice.entity_id, optval.value
|
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.0.
|
4
|
+
version: 0.0.3
|
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-01-
|
11
|
+
date: 2016-01-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rawgento_models
|