| Line 704... |
Line 704... |
| 704 |
else:
|
704 |
else:
|
| 705 |
actionsMap[x.store_product_id] = {'action':action,'rank':None,'dealRankPoints':None}
|
705 |
actionsMap[x.store_product_id] = {'action':action,'rank':None,'dealRankPoints':None}
|
| 706 |
|
706 |
|
| 707 |
session.close()
|
707 |
session.close()
|
| 708 |
|
708 |
|
| 709 |
pseudo_count = 0
|
709 |
pseudo_count = 1
|
| - |
|
710 |
inserted_count = 0
|
| 710 |
|
711 |
try:
|
| 711 |
if actionsMap:
|
712 |
if actionsMap:
|
| 712 |
for k,v in actionsMap.iteritems():
|
713 |
for k,v in actionsMap.iteritems():
|
| 713 |
tmp_deal = get_mongo_connection().Catalog.Deals.find_one({'_id':k})
|
714 |
tmp_deal = get_mongo_connection().Catalog.Deals.find_one({'_id':k})
|
| 714 |
print tmp_deal
|
715 |
print tmp_deal
|
| 715 |
if tmp_deal is None and tmp_deal['category_id']!=6 and (tmp_deal['showDeal']!=1 or tmp_deal['prepaidDeal']!=1) :
|
716 |
if tmp_deal is None and tmp_deal['category_id']!=6 and (tmp_deal['showDeal']!=1 or tmp_deal['prepaidDeal']!=1) :
|
| 716 |
print "Continue"
|
- |
|
| 717 |
v['rank'] = None
|
- |
|
| 718 |
continue
|
- |
|
| 719 |
if v['action'] ==0:
|
- |
|
| 720 |
leastDealRankPoints = list(get_mongo_connection().Catalog.Deals.find({'subCategoryId':tmp_deal.get('subCategoryId')}).sort([('dealRankPoints',pymongo.ASCENDING)]).limit(1))
|
- |
|
| 721 |
if len(leastDealRankPoints) == 0 or leastDealRankPoints[0].get('dealRankPoints') is None:
|
- |
|
| 722 |
print "Continue2"
|
717 |
print "Continue"
|
| 723 |
v['rank'] = None
|
718 |
v['rank'] = None
|
| 724 |
continue
|
719 |
continue
|
| - |
|
720 |
if v['action'] ==0:
|
| - |
|
721 |
leastDealRankPoints = list(get_mongo_connection().Catalog.Deals.find({'subCategoryId':tmp_deal.get('subCategoryId')}).sort([('dealRankPoints',pymongo.ASCENDING)]).limit(1))
|
| - |
|
722 |
if len(leastDealRankPoints) == 0 or leastDealRankPoints[0].get('dealRankPoints') is None:
|
| - |
|
723 |
print "Continue2"
|
| - |
|
724 |
v['rank'] = None
|
| - |
|
725 |
continue
|
| 725 |
v['dealRankPoints'] = leastDealRankPoints[0]['dealRankPoints'] - 1
|
726 |
v['dealRankPoints'] = leastDealRankPoints[0]['dealRankPoints'] - 1
|
| 726 |
v['rank'] = 999999
|
727 |
v['rank'] = 999999
|
| 727 |
else:
|
728 |
else:
|
| 728 |
v['dealRankPoints'] = tmp_deal.get('dealRankPoints')
|
729 |
v['dealRankPoints'] = tmp_deal.get('dealRankPoints')
|
| - |
|
730 |
except:
|
| - |
|
731 |
print "Exception in action map"
|
| - |
|
732 |
traceback.print_exc()
|
| 729 |
|
733 |
|
| 730 |
for deal in accessories_deals:
|
734 |
for deal in accessories_deals:
|
| 731 |
|
735 |
|
| 732 |
try:
|
736 |
try:
|
| 733 |
fd_bundles.remove(deal.get('skuBundleId'))
|
737 |
fd_bundles.remove(deal.get('skuBundleId'))
|
| 734 |
except:
|
738 |
except:
|
| 735 |
pass
|
739 |
pass
|
| - |
|
740 |
try:
|
| 736 |
if actionsMap and actionsMap.get(deal['_id'])!=None:
|
741 |
if actionsMap and actionsMap.get(deal['_id'])!=None:
|
| 737 |
if actionsMap.get(deal['_id']).get('action') ==1 and actionsMap.get(deal['_id']).get('rank')!=None:
|
742 |
if actionsMap.get(deal['_id']).get('action') ==1 and actionsMap.get(deal['_id']).get('rank')!=None:
|
| 738 |
actionRank = actionsMap.get(deal['_id']).get('rank')
|
743 |
actionRank = actionsMap.get(deal['_id']).get('rank')
|
| 739 |
if actionRank < pseudo_count:
|
744 |
if actionRank < pseudo_count:
|
| 740 |
deal['dealRankPoints'] = accessories_deals[actionRank-1]['dealRankPoints'] +.5 + pseudo_count
|
745 |
deal['dealRankPoints'] = accessories_deals[actionRank-1]['dealRankPoints'] +.5 + inserted_count
|
| - |
|
746 |
actionsMap.get(deal['_id'])['dealRankPoints'] = deal['dealRankPoints']
|
| 741 |
pseudo_count = pseudo_count+1
|
747 |
inserted_count = inserted_count+1
|
| 742 |
elif actionsMap.get(deal['_id']).get('action') ==0 and actionsMap.get(deal['_id']).get('rank')!=None:
|
748 |
elif actionsMap.get(deal['_id']).get('action') ==0 and actionsMap.get(deal['_id']).get('rank')!=None:
|
| 743 |
deal['dealRankPoints'] = actionsMap.get(deal['_id']).get('dealRankPoints')
|
749 |
deal['dealRankPoints'] = actionsMap.get(deal['_id']).get('dealRankPoints')
|
| - |
|
750 |
actionsMap.get(deal['_id'])['dealRankPoints'] = deal['dealRankPoints']
|
| 744 |
else:
|
751 |
else:
|
| 745 |
pass
|
752 |
pass
|
| 746 |
for k, v in actionsMap.iteritems():
|
753 |
pseudo_count = pseudo_count+1
|
| 747 |
print k,
|
754 |
except:
|
| 748 |
print '\t',
|
755 |
print "Exception while arranging dealRankPoints"
|
| 749 |
print v
|
756 |
traceback.print_exc()
|
| 750 |
|
757 |
|
| 751 |
accessories_deals = sorted(accessories_deals, key = lambda x: (x['dealRankPoints'],x['bestSellerPoints'], x['nlcPoints'], x['rank']),reverse=True)
|
758 |
accessories_deals = sorted(accessories_deals, key = lambda x: (x['dealRankPoints'],x['bestSellerPoints'], x['nlcPoints'], x['rank']),reverse=True)
|
| 752 |
|
759 |
|
| 753 |
if len(fd_bundles) > 0:
|
760 |
if len(fd_bundles) > 0:
|
| 754 |
print "There is still bundle in feature deals.Lets add info"
|
761 |
print "There is still bundle in feature deals.Lets add info"
|