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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9ffe7e69a62608c8a489a4f75fdf3af2bd6dc76b
4
- data.tar.gz: 407d488bc8d0b6e7a79e64bd2e9f913196d88183
3
+ metadata.gz: 9aaa741a762100f9b61f54a2f5debd2ac75fbf40
4
+ data.tar.gz: 1db216b834cfe1114f067fd4a426da51b3006ced
5
5
  SHA512:
6
- metadata.gz: 64df84bdf1082f5715269395ad08232001b5e43bb45768aa5953959a0356ffaaeb49e490fbb8e6124beb68b702015ac11c6b351427cfea3031f4f9b0a98812f6
7
- data.tar.gz: 3f606884ad0028df58142e1a1ab8da9af5b32ffd7b7cb61e6e7a941d6d48b7931f0d7698adcccb2688c72c430fccc5008b88d590f93cd94deeccc11a611bca9d
6
+ metadata.gz: fe2119ffac12d5be22e1d950ab9b65bb255a532f584271cafca2d31de750a5d056f04d6414f42bdbbd40d48157703da4a25564bec7cd3144c7d781aa6e7f2c2a
7
+ data.tar.gz: 05ae53d5dc24ca0b86c5293649e7069aefa2cea3fb91e2a1e43621da7fd68de05690fe24760c5b681267a8298e6aeea9f586faa963c84777d9290398c756fdcc
@@ -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
 
@@ -1,3 +1,3 @@
1
1
  module RawgentoDB
2
- VERSION = "0.1.3"
2
+ VERSION = "0.2.0"
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.1.3
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-07 00:00:00.000000000 Z
11
+ date: 2016-08-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rawgento_models