| Line 619... |
Line 619... |
| 619 |
else:
|
619 |
else:
|
| 620 |
return cashBack.get(category_id)
|
620 |
return cashBack.get(category_id)
|
| 621 |
else:
|
621 |
else:
|
| 622 |
return {}
|
622 |
return {}
|
| 623 |
|
623 |
|
| - |
|
624 |
def getDealRank(identifier, source_id, userId):
|
| - |
|
625 |
if source_id in (1,2,4,5):
|
| - |
|
626 |
skuData = list(get_mongo_connection().Catalog.MasterData.find({'identifier':identifier.strip(), 'source_id':source_id}))
|
| - |
|
627 |
elif source_id == 3:
|
| - |
|
628 |
skuData = list(get_mongo_connection().Catalog.MasterData.find({'secondaryIdentifier':identifier.strip(), 'source_id':source_id}))
|
| - |
|
629 |
else:
|
| - |
|
630 |
return {0,'No product found'}
|
| - |
|
631 |
user_specific_deals = mc.get(str(userId))
|
| - |
|
632 |
if user_specific_deals is None:
|
| - |
|
633 |
__populateCache(userId)
|
| - |
|
634 |
user_specific_deals = mc.get(str(userId))
|
| - |
|
635 |
else:
|
| - |
|
636 |
print "Getting user deals from cache"
|
| - |
|
637 |
category_id = skuData[0]['category_id']
|
| - |
|
638 |
category_specific_deals = user_specific_deals.get(category_id)
|
| - |
|
639 |
if category_specific_deals is None or len(category_specific_deals) ==0:
|
| - |
|
640 |
return {0,'Category specific deals is empty'}
|
| - |
|
641 |
sorted_deals = sorted(category_specific_deals, key = lambda x: (x['persPoints'],x['totalPoints'],x['bestSellerPoints'], x['nlcPoints'], x['rank']),reverse=True)
|
| - |
|
642 |
rank = 1
|
| - |
|
643 |
for sorted_deal in sorted_deals:
|
| - |
|
644 |
if sorted_deal['_id'] == skuData[0]['_id']:
|
| - |
|
645 |
return {rank,'Rank found'}
|
| - |
|
646 |
break
|
| - |
|
647 |
rank+=1
|
| - |
|
648 |
return {0,'Rank not found'}
|
| - |
|
649 |
|
| - |
|
650 |
|
| 624 |
def getCashBackDetails(identifier, source_id):
|
651 |
def getCashBackDetails(identifier, source_id):
|
| 625 |
if not bool(mc.get("category_cash_back")):
|
652 |
if not bool(mc.get("category_cash_back")):
|
| 626 |
populateCashBack()
|
653 |
populateCashBack()
|
| 627 |
|
654 |
|
| 628 |
"""Need to add item level cashback, no data available right now."""
|
655 |
"""Need to add item level cashback, no data available right now."""
|
| Line 1032... |
Line 1059... |
| 1032 |
_id = data.pop('_id')
|
1059 |
_id = data.pop('_id')
|
| 1033 |
skuBundleId = data.pop('skuBundleId')
|
1060 |
skuBundleId = data.pop('skuBundleId')
|
| 1034 |
data['updatedOn'] = to_java_date(datetime.now())
|
1061 |
data['updatedOn'] = to_java_date(datetime.now())
|
| 1035 |
data['identifier'] = str(data['identifier'])
|
1062 |
data['identifier'] = str(data['identifier'])
|
| 1036 |
data['secondaryIdentifier'] = str(data['secondaryIdentifier'])
|
1063 |
data['secondaryIdentifier'] = str(data['secondaryIdentifier'])
|
| - |
|
1064 |
data['brand_id'] = __getBrandIdForBrand(data['brand'], data['category_id'])
|
| 1037 |
get_mongo_connection().Catalog.MasterData.update({'_id':_id},{"$set":data},upsert=False)
|
1065 |
get_mongo_connection().Catalog.MasterData.update({'_id':_id},{"$set":data},upsert=False)
|
| 1038 |
return {1:'Data updated successfully.'}
|
1066 |
return {1:'Data updated successfully.'}
|
| 1039 |
else:
|
1067 |
else:
|
| 1040 |
_id = data.pop('_id')
|
1068 |
_id = data.pop('_id')
|
| 1041 |
skuBundleId = data.pop('skuBundleId')
|
1069 |
skuBundleId = data.pop('skuBundleId')
|
| 1042 |
data['updatedOn'] = to_java_date(datetime.now())
|
1070 |
data['updatedOn'] = to_java_date(datetime.now())
|
| 1043 |
data['identifier'] = str(data['identifier'])
|
1071 |
data['identifier'] = str(data['identifier'])
|
| 1044 |
data['secondaryIdentifier'] = str(data['secondaryIdentifier'])
|
1072 |
data['secondaryIdentifier'] = str(data['secondaryIdentifier'])
|
| - |
|
1073 |
data['brand_id'] = __getBrandIdForBrand(data['brand'], data['category_id'])
|
| 1045 |
get_mongo_connection().Catalog.MasterData.update({'_id':_id},{"$set":data},upsert=False)
|
1074 |
get_mongo_connection().Catalog.MasterData.update({'_id':_id},{"$set":data},upsert=False)
|
| 1046 |
similarItems = get_mongo_connection().Catalog.MasterData.find({'skuBundleId':skuBundleId})
|
1075 |
similarItems = get_mongo_connection().Catalog.MasterData.find({'skuBundleId':skuBundleId})
|
| 1047 |
for item in similarItems:
|
1076 |
for item in similarItems:
|
| 1048 |
if item['_id'] == _id:
|
1077 |
if item['_id'] == _id:
|
| 1049 |
continue
|
1078 |
continue
|
| Line 1054... |
Line 1083... |
| 1054 |
item['tagline'] = data['tagline']
|
1083 |
item['tagline'] = data['tagline']
|
| 1055 |
item['is_shortage'] = data['is_shortage']
|
1084 |
item['is_shortage'] = data['is_shortage']
|
| 1056 |
item['mrp'] = data['mrp']
|
1085 |
item['mrp'] = data['mrp']
|
| 1057 |
item['status'] = data['status']
|
1086 |
item['status'] = data['status']
|
| 1058 |
item['maxPrice'] = data['maxPrice']
|
1087 |
item['maxPrice'] = data['maxPrice']
|
| - |
|
1088 |
item['brand_id'] = data['brand_id']
|
| 1059 |
similar_item_id = item.pop('_id')
|
1089 |
similar_item_id = item.pop('_id')
|
| 1060 |
get_mongo_connection().Catalog.MasterData.update({'_id':similar_item_id},{"$set":item},upsert=False)
|
1090 |
get_mongo_connection().Catalog.MasterData.update({'_id':similar_item_id},{"$set":item},upsert=False)
|
| 1061 |
return {1:'Data updated successfully.'}
|
1091 |
return {1:'Data updated successfully.'}
|
| 1062 |
|
1092 |
|
| 1063 |
def getLiveCricScore():
|
1093 |
def getLiveCricScore():
|