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 +4 -4
- data/lib/product_update_single.rb +22 -17
- data/lib/product_update_single/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: edd90473f786be846aa4888f3f605ada728ee087
|
4
|
+
data.tar.gz: 66ec5500f16a437da9f11b4db2a8667163d59fc3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
36
|
-
|
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
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
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
|
-
|
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.
|
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|
|
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
|
+
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-
|
11
|
+
date: 2017-04-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|