| Line 17... |
Line 17... |
| 17 |
now = datetime.now()
|
17 |
now = datetime.now()
|
| 18 |
|
18 |
|
| 19 |
class __SkuInfo:
|
19 |
class __SkuInfo:
|
| 20 |
|
20 |
|
| 21 |
def __init__(self, _id, skuBundleId, category_id, mrp, available_price, source_id, rank, maxNlc, minNlc, schemeAmount, minDiscount, \
|
21 |
def __init__(self, _id, skuBundleId, category_id, mrp, available_price, source_id, rank, maxNlc, minNlc, schemeAmount, minDiscount, \
|
| 22 |
maxDiscount, discountType, dp, nlcPoints, bestSellerPoints, totalPoints, status, in_stock, maxprice):
|
22 |
maxDiscount, discountType, dp, nlcPoints, bestSellerPoints, totalPoints, status, in_stock, maxprice, brand):
|
| 23 |
self._id = _id
|
23 |
self._id = _id
|
| 24 |
self.skuBundleId = skuBundleId
|
24 |
self.skuBundleId = skuBundleId
|
| 25 |
self.category_id = category_id
|
25 |
self.category_id = category_id
|
| 26 |
self.mrp = mrp
|
26 |
self.mrp = mrp
|
| 27 |
self.available_price = available_price
|
27 |
self.available_price = available_price
|
| Line 38... |
Line 38... |
| 38 |
self.bestSellerPoints = bestSellerPoints
|
38 |
self.bestSellerPoints = bestSellerPoints
|
| 39 |
self.totalPoints = totalPoints
|
39 |
self.totalPoints = totalPoints
|
| 40 |
self.status = status
|
40 |
self.status = status
|
| 41 |
self.in_stock = in_stock
|
41 |
self.in_stock = in_stock
|
| 42 |
self.maxprice = maxprice
|
42 |
self.maxprice = maxprice
|
| - |
|
43 |
self.brand = brand
|
| 43 |
|
44 |
|
| 44 |
|
45 |
|
| 45 |
def get_mongo_connection(host='localhost', port=27017):
|
46 |
def get_mongo_connection(host='localhost', port=27017):
|
| 46 |
global con
|
47 |
global con
|
| 47 |
if con is None:
|
48 |
if con is None:
|
| Line 67... |
Line 68... |
| 67 |
#topSkus = collection.find( {'_id':664})
|
68 |
#topSkus = collection.find( {'_id':664})
|
| 68 |
for sku in topSkus:
|
69 |
for sku in topSkus:
|
| 69 |
"""Fix this """
|
70 |
"""Fix this """
|
| 70 |
#TODO Compute deal flags else where.
|
71 |
#TODO Compute deal flags else where.
|
| 71 |
info = __SkuInfo(sku['_id'], sku['skuBundleId'], sku['category_id'], sku['mrp'], sku['available_price'], sku['source_id'], sku['rank'], None, None, 0.0, None, \
|
72 |
info = __SkuInfo(sku['_id'], sku['skuBundleId'], sku['category_id'], sku['mrp'], sku['available_price'], sku['source_id'], sku['rank'], None, None, 0.0, None, \
|
| 72 |
None, None, None, None, None, None, sku['status'], sku['in_stock'],None)
|
73 |
None, None, None, None, None, None, sku['status'], sku['in_stock'],None,sku['brand'].strip().upper())
|
| 73 |
exceptionalNlc = list(get_mongo_connection().Catalog.ExceptionalNlc.find( {"$and" : [ {'sku':info._id}, {'overrideNlc':1} ]} ))
|
74 |
exceptionalNlc = list(get_mongo_connection().Catalog.ExceptionalNlc.find( {"$and" : [ {'sku':info._id}, {'overrideNlc':1} ]} ))
|
| 74 |
if len(exceptionalNlc) > 0:
|
75 |
if len(exceptionalNlc) > 0:
|
| 75 |
"""Exceptional nlc found, no need to calculate max and min R-nlc"""
|
76 |
"""Exceptional nlc found, no need to calculate max and min R-nlc"""
|
| 76 |
info.maxNlc = exceptionalNlc[0]['maxNlc']
|
77 |
info.maxNlc = exceptionalNlc[0]['maxNlc']
|
| 77 |
info.minNlc = exceptionalNlc[0]['minNlc']
|
78 |
info.minNlc = exceptionalNlc[0]['minNlc']
|
| Line 97... |
Line 98... |
| 97 |
info.minDiscount = skuDiscount[0]['min_discount']
|
98 |
info.minDiscount = skuDiscount[0]['min_discount']
|
| 98 |
info.discountType = DISCOUNT_TYPE.get(skuDiscount[0]['discountType'].upper())
|
99 |
info.discountType = DISCOUNT_TYPE.get(skuDiscount[0]['discountType'].upper())
|
| 99 |
LATEST_UPDATED_ITEMS.append(info)
|
100 |
LATEST_UPDATED_ITEMS.append(info)
|
| 100 |
continue
|
101 |
continue
|
| 101 |
|
102 |
|
| 102 |
categoryDiscount = list(get_mongo_connection().Catalog.CategoryDiscount.find( {"$and" : [{'brand':sku['brand'].upper()}, {'category_id':sku['category_id']} ]} ))
|
103 |
categoryDiscount = list(get_mongo_connection().Catalog.CategoryDiscount.find( {"$and" : [{'brand':sku['brand'].strip().upper()}, {'category_id':sku['category_id']} ]} ))
|
| 103 |
if len(categoryDiscount) > 0:
|
104 |
if len(categoryDiscount) > 0:
|
| 104 |
info.maxDiscount = categoryDiscount[0]['max_discount']
|
105 |
info.maxDiscount = categoryDiscount[0]['max_discount']
|
| 105 |
info.minDiscount = categoryDiscount[0]['min_discount']
|
106 |
info.minDiscount = categoryDiscount[0]['min_discount']
|
| 106 |
info.discountType = DISCOUNT_TYPE.get(categoryDiscount[0]['discountType'].upper())
|
107 |
info.discountType = DISCOUNT_TYPE.get(categoryDiscount[0]['discountType'].upper())
|
| 107 |
|
108 |
|