product_update_single 0.1.4 → 0.1.5

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: 34279169d49c00c21b86a4677e14e5d30e53c55b
4
- data.tar.gz: f643768a33bbb8f6ed8066e77eabb0d19c5d120e
3
+ metadata.gz: edd90473f786be846aa4888f3f605ada728ee087
4
+ data.tar.gz: 66ec5500f16a437da9f11b4db2a8667163d59fc3
5
5
  SHA512:
6
- metadata.gz: 28eb1eea0f226a989fc8c0c34aafadd18bce9e2d074a3b0ff68de1f8a4363b87ef797d4fadf5040c74b980574a33f823c2136a7a115cd586ff7551d2da022d80
7
- data.tar.gz: 599728471c06dddef72a4efdcefe81b21e0b8de4af783a5f933ac4fe99965c003375e02ae4fe4e486fa53bf645dbf860cbb762f1e89f3aa542c6e80cdc15096c
6
+ metadata.gz: 88cc14a997415fd44ed3c2936cb0c8c73383f308376bf87345292c3504c567bd0f195a0090d16f93abe701e930f42d13ff4b2674a8158b687a99531ca699d769
7
+ data.tar.gz: 363b497236feb376bbef443485156e5fd65857e3e357ef6496c7b857c69a5f67ed9c159917de64938e91314a01f5a8efa09e4e93dc04cb59e3b63b61dd74c451
@@ -31,30 +31,35 @@ class ProductUpdateSingleton
31
31
  end
32
32
 
33
33
  #this method updates the count column in the product model based on the quantity of products sold.
34
- def count_update
35
- @order_confirmed = Order.last
36
- @order_record = OrderItem.where(order_id: @order_confirmed.id)
34
+ def count_update(order_records)
35
+ #@order_confirmed = Order.last
36
+ #@order_record = OrderItem.where(order_id: @order_confirmed.id)
37
+ @store_memory = []
38
+ @order_record = order_records
37
39
  @order_record.each do |order_record|
38
- @product_count_update = Product.find(order_record.product_id)
39
- if(@product_count_update.count?)
40
- puts(@product_count_update)
41
- @product_count_update.count += order_record.quantity
42
- else
43
- @product_count_update.count = 0
44
- @product_count_update.count += order_record.quantity
45
- end
46
- puts("inside count update function and order item should have been initiated by now")
47
- #@product_count_update.quantityAvailable -= order_record.quantity
48
- @product_count_update.save
40
+ @product_count_update = Product.find(order_record.product_id)
41
+ if(@product_count_update.count?)
42
+ puts(@product_count_update)
43
+ @product_count_update.count += order_record.quantity
44
+ else
45
+ @product_count_update.count = 0
46
+ @product_count_update.count += order_record.quantity
47
+ end
48
+ puts("inside count update function and order item should have been initiated by now")
49
+ #@product_count_update.quantityAvailable -= order_record.quantity
50
+ @product_count_update.save
51
+ @store_memory << @product_count_update.store_detail_id
49
52
  end
50
53
  puts("count update should be completed by now and quantity of product ordered should be have been subtracted in the product")
51
- self.hit_counter
54
+ @store_memory.uniq.each do |call_hit|
55
+ self.hit_counter(call_hit)
56
+ end
52
57
  end
53
58
 
54
59
  #this method is triggered by the count update method internally to rank the products by its count updated previously.
55
- def hit_counter
60
+ def hit_counter(store_id)
56
61
  @count_iterate = 1
57
- @prod = Product.all
62
+ @prod = Product.where(store_detail_id: store_id)
58
63
  @sorted_hit = @prod.order('count desc')
59
64
  puts("Inside hit update function and product is initiated now, it should start updated the hit ranking")
60
65
  @sorted_hit.each do |pro|
@@ -1,3 +1,3 @@
1
1
  module ProductUpdateSingle
2
- VERSION = "0.1.4"
2
+ VERSION = "0.1.5"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: product_update_single
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kishore Kumar
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-04-18 00:00:00.000000000 Z
11
+ date: 2017-04-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler