| Line 621... |
Line 621... |
| 621 |
if source_id in (1,2,4,5):
|
621 |
if source_id in (1,2,4,5):
|
| 622 |
skuData = list(get_mongo_connection().Catalog.MasterData.find({'identifier':identifier.strip(), 'source_id':source_id}))
|
622 |
skuData = list(get_mongo_connection().Catalog.MasterData.find({'identifier':identifier.strip(), 'source_id':source_id}))
|
| 623 |
elif source_id == 3:
|
623 |
elif source_id == 3:
|
| 624 |
skuData = list(get_mongo_connection().Catalog.MasterData.find({'secondaryIdentifier':identifier.strip(), 'source_id':source_id}))
|
624 |
skuData = list(get_mongo_connection().Catalog.MasterData.find({'secondaryIdentifier':identifier.strip(), 'source_id':source_id}))
|
| 625 |
else:
|
625 |
else:
|
| 626 |
return {'rank':0, 'description':'Source not valid'}
|
626 |
return {'rank':0, 'description':'Source not valid','maxNlc':None, 'minNlC':None,'status':None,'dp':None}
|
| 627 |
if len(skuData) == 0:
|
627 |
if len(skuData) == 0:
|
| 628 |
return {'rank':0, 'description':'No matching product identifier found'}
|
628 |
return {'rank':0, 'description':'No matching product identifier found','maxNlc':None, 'minNlC':None,'status':None,'dp':None}
|
| 629 |
user_specific_deals = mc.get(str(userId))
|
629 |
user_specific_deals = mc.get(str(userId))
|
| 630 |
if user_specific_deals is None:
|
630 |
if user_specific_deals is None:
|
| 631 |
__populateCache(userId)
|
631 |
__populateCache(userId)
|
| 632 |
user_specific_deals = mc.get(str(userId))
|
632 |
user_specific_deals = mc.get(str(userId))
|
| 633 |
else:
|
633 |
else:
|
| 634 |
print "Getting user deals from cache"
|
634 |
print "Getting user deals from cache"
|
| 635 |
category_id = skuData[0]['category_id']
|
635 |
category_id = skuData[0]['category_id']
|
| 636 |
category_specific_deals = user_specific_deals.get(category_id)
|
636 |
category_specific_deals = user_specific_deals.get(category_id)
|
| - |
|
637 |
|
| - |
|
638 |
dealsData = get_mongo_connection().Catalog.Deals.find_one({'skuBundleId':skuData[0]['skuBundleId']})
|
| - |
|
639 |
if dealsData is None:
|
| - |
|
640 |
dealsData = {}
|
| - |
|
641 |
|
| 637 |
if category_specific_deals is None or len(category_specific_deals) ==0:
|
642 |
if category_specific_deals is None or len(category_specific_deals) ==0:
|
| 638 |
return {'rank':0,'description':'Category specific deals is empty'}
|
643 |
return {'rank':0,'description':'Category specific deals is empty','maxNlc':dealsData.get('maxNlc'),'minNlc':dealsData.get('minNlc'),'status':dealsData.get('status'),'dp':dealsData.get('dp')}
|
| 639 |
sorted_deals = sorted(category_specific_deals, key = lambda x: (x['persPoints'],x['totalPoints'],x['bestSellerPoints'], x['nlcPoints'], x['rank']),reverse=True)
|
644 |
sorted_deals = sorted(category_specific_deals, key = lambda x: (x['persPoints'],x['totalPoints'],x['bestSellerPoints'], x['nlcPoints'], x['rank']),reverse=True)
|
| 640 |
sortedMap = {}
|
645 |
sortedMap = {}
|
| 641 |
rankMap = {}
|
646 |
rankMap = {}
|
| 642 |
rank = 0
|
647 |
rank = 0
|
| 643 |
for sorted_deal in sorted_deals:
|
648 |
for sorted_deal in sorted_deals:
|
| Line 651... |
Line 656... |
| 651 |
rankMap[(sortedMap.get(sorted_deal['skuBundleId']).keys())[0]] = temp_list
|
656 |
rankMap[(sortedMap.get(sorted_deal['skuBundleId']).keys())[0]] = temp_list
|
| 652 |
|
657 |
|
| 653 |
for dealRank ,dealList in rankMap.iteritems():
|
658 |
for dealRank ,dealList in rankMap.iteritems():
|
| 654 |
for d in dealList:
|
659 |
for d in dealList:
|
| 655 |
if d['skuBundleId'] == skuData[0]['skuBundleId']:
|
660 |
if d['skuBundleId'] == skuData[0]['skuBundleId']:
|
| 656 |
return {'rank':dealRank+1,'description':'Rank found'}
|
661 |
return {'rank':dealRank+1,'description':'Rank found','maxNlc':dealsData.get('maxNlc'),'minNlc':dealsData.get('minNlc'),'status':dealsData.get('status'),'dp':dealsData.get('dp')}
|
| 657 |
|
662 |
|
| 658 |
return {'rank':0,'description':'Rank not found'}
|
663 |
return {'rank':0,'description':'Rank not found','maxNlc':dealsData.get('maxNlc'),'minNlc':dealsData.get('minNlc'),'status':dealsData.get('status'),'dp':dealsData.get('dp')}
|
| 659 |
|
664 |
|
| 660 |
|
665 |
|
| 661 |
def getCashBackDetails(identifier, source_id):
|
666 |
def getCashBackDetails(identifier, source_id):
|
| 662 |
if not bool(mc.get("category_cash_back")):
|
667 |
if not bool(mc.get("category_cash_back")):
|
| 663 |
populateCashBack()
|
668 |
populateCashBack()
|