rawgento_db 0.1.3 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rawgento_db/query.rb +12 -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: 9aaa741a762100f9b61f54a2f5debd2ac75fbf40
|
4
|
+
data.tar.gz: 1db216b834cfe1114f067fd4a426da51b3006ced
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fe2119ffac12d5be22e1d950ab9b65bb255a532f584271cafca2d31de750a5d056f04d6414f42bdbbd40d48157703da4a25564bec7cd3144c7d781aa6e7f2c2a
|
7
|
+
data.tar.gz: 05ae53d5dc24ca0b86c5293649e7069aefa2cea3fb91e2a1e43621da7fd68de05690fe24760c5b681267a8298e6aeea9f586faa963c84777d9290398c756fdcc
|
data/lib/rawgento_db/query.rb
CHANGED
@@ -107,6 +107,17 @@ module RawgentoDB
|
|
107
107
|
end
|
108
108
|
end
|
109
109
|
|
110
|
+
def self.first_sales product_ids, settings=RawgentoDB.settings
|
111
|
+
query = "SELECT MIN(period), product_id "\
|
112
|
+
"FROM sales_bestsellers_aggregated_daily "\
|
113
|
+
"WHERE product_id in (%s) "\
|
114
|
+
"GROUP BY product_id" % [product_ids.join(",")]
|
115
|
+
result = client(settings).query(query)
|
116
|
+
result.map do |r|
|
117
|
+
[r['product_id'], r['MIN(period)']]
|
118
|
+
end.to_h
|
119
|
+
end
|
120
|
+
|
110
121
|
def self.num_sales_since day, product_ids, settings=RawgentoDB.settings
|
111
122
|
query = "SELECT SUM(qty_ordered), product_id "\
|
112
123
|
"FROM sales_bestsellers_aggregated_daily "\
|
@@ -116,7 +127,7 @@ module RawgentoDB
|
|
116
127
|
|
117
128
|
result = client(settings).query(query)
|
118
129
|
result.map do |r|
|
119
|
-
[r['product_id'], r['SUM(qty_ordered)'].to_i]
|
130
|
+
[r['product_id'], ProductQty.new(r['product_id'], r['SUM(qty_ordered)'].to_i)]
|
120
131
|
end.to_h
|
121
132
|
end
|
122
133
|
|
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.
|
4
|
+
version: 0.2.0
|
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-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rawgento_models
|