rawgento_db 0.0.3 → 0.1.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: c83957aeeb965ba0c52cb85ec1050676196a5606
4
- data.tar.gz: bde063b48ba8338f06a4c3593032baebf360d25e
3
+ metadata.gz: 4622e7707a432c99a1e294cd1d78250d058d9068
4
+ data.tar.gz: b6a2811e39bf69befb9afb9d18fe5ce5c677f4ab
5
5
  SHA512:
6
- metadata.gz: 240f5c485cfac378044b2cf7018117ebee914da9ef74ebff079d4500a03568b3742524615e2da3647a35c23d812b2b7dd34b72156764fc7bddbf0def860126aa
7
- data.tar.gz: f33df13b5d0dea5b6e7da85082b6bb76243a8bcf613cc235666c032024b09650efe9d74d62dfc99a2d81df4087f9cd97fb7bec082be9a242a62ba04c025cb86d
6
+ metadata.gz: 867da4b5037e036803c25536a81118d84ed79dbe0b1c2fd2181df206aad367c891a53402ed7d45e40e55a92eb7291a400ac5757e86d433185a8e4687d7873531
7
+ data.tar.gz: 3a26b4fe0f942704b7445dbce6a557f050bcc587dd11d47e23cb25172740211e82c5eff3779e40904130ff7948e767f0a745855a796af95768bf7ff8dfbe9f9a
@@ -38,6 +38,24 @@ module RawgentoDB
38
38
  end
39
39
  end
40
40
 
41
+ # Newer version might require query via entity_id
42
+ # array('aggregation' => $collection->getResource()->getTable('sales/bestsellers_aggregated_monthly')),
43
+ # "e.entity_id = aggregation.product_id AND aggregation.store_id={$storeId} AND aggregation.period BETWEEN '{$fromDate}' AND '{$toDate}'",
44
+ # array('SUM(aggregation.qty_ordered) AS sold_quantity')
45
+
46
+ def self.sales_daily_between product_id, from_date, to_date, settings=RawgentoDB.settings
47
+ min_date, max_date = [from_date, to_date].minmax
48
+ query = 'SELECT * '\
49
+ 'FROM sales_bestsellers_aggregated_daily '\
50
+ 'WHERE product_id = %d AND '\
51
+ 'period >= \'%s\' AND period <= \'%s\' '\
52
+ 'ORDER BY PERIOD DESC' % [product_id, min_date.strftime, max_date.strftime]
53
+ result = client(settings).query(query)
54
+ result.map do |r|
55
+ [r['period'], "%1.0f" % r['qty_ordered']]
56
+ end
57
+ end
58
+
41
59
  def self.sales_monthly product_id, settings=RawgentoDB.settings
42
60
  result = client(settings).query('SELECT * '\
43
61
  'FROM sales_bestsellers_aggregated_monthly '\
@@ -1,3 +1,3 @@
1
1
  module RawgentoDB
2
- VERSION = "0.0.3"
2
+ VERSION = "0.1.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.0.3
4
+ version: 0.1.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-01-29 00:00:00.000000000 Z
11
+ date: 2016-05-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rawgento_models