Subversion Repositories SmartDukaan

Rev

Rev 19597 | Rev 19604 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 19597 Rev 19599
Line 699... Line 699...
699
    accessories_deals = list(get_mongo_connection().Catalog.Deals.find({"$and":outer_query},{'_id':1,'category_id':1,'brand':1,'bestSellerPoints':1,'nlcPoints':1,'totalPoints':1,'dealRankPoints':1,'rank':1,'available_price':1,'dealType':1,'source_id':1,'brand_id':1,'skuBundleId':1,'dp':1, 'showDp':1, 'gross_price':1, 'subCategoryId':1,'netPriceAfterCashBack':1}).sort([('dealRankPoints',pymongo.DESCENDING),('bestSellerPoints',pymongo.DESCENDING)]))
699
    accessories_deals = list(get_mongo_connection().Catalog.Deals.find({"$and":outer_query},{'_id':1,'category_id':1,'brand':1,'bestSellerPoints':1,'nlcPoints':1,'totalPoints':1,'dealRankPoints':1,'rank':1,'available_price':1,'dealType':1,'source_id':1,'brand_id':1,'skuBundleId':1,'dp':1, 'showDp':1, 'gross_price':1, 'subCategoryId':1,'netPriceAfterCashBack':1}).sort([('dealRankPoints',pymongo.DESCENDING),('bestSellerPoints',pymongo.DESCENDING)]))
700
    
700
    
701
    actionsMap = {}
701
    actionsMap = {}
702
    actionRank = 3
702
    actionRank = 3
703
    try:
703
    try:
704
        for x in session.query(user_actions).filter_by(user_id=userId).order_by(asc(user_actions.created)).all():
704
        favourite_data = session.query(user_actions).filter_by(user_id=userId).order_by(asc(user_actions.created)).all()
-
 
705
        favourite_ids = [x.store_product_id for x in favourite_data]
-
 
706
        master_ids = list(get_mongo_connection().Catalog.MasterData.find({'_id':{"$in":favourite_ids},'category_id':6},{'_id':1}))
-
 
707
        accessory_ids = [x['_id'] for x in master_ids]
-
 
708
        for x in favourite_data:
-
 
709
            if x.store_product_id not in accessory_ids:
-
 
710
                continue
705
            action = 1 if x.action == 'like' else 0
711
            action = 1 if x.action == 'like' else 0
706
            if action==1:
712
            if action==1:
707
                actionsMap[x.store_product_id] = {'action':action,'rank':actionRank,'dealRankPoints':None}
713
                actionsMap[x.store_product_id] = {'action':action,'rank':actionRank,'dealRankPoints':None}
708
                actionRank = actionRank+3
714
                actionRank = actionRank+3
709
            else:
715
            else:
710
                actionsMap[x.store_product_id] = {'action':action,'rank':None,'dealRankPoints':None}
716
                actionsMap[x.store_product_id] = {'action':action,'rank':None,'dealRankPoints':None}
711
    except:
717
    except:
712
        pass
718
        print "Exception in actionsMap creation"
713
    finally:    
719
    finally:    
714
        session.close()
720
        session.close()
715
    
721
    
716
    pseudo_count = 1
722
    pseudo_count = 1
717
    inserted_count = 0
723
    inserted_count = 0
718
    try:
724
    try:
719
        if actionsMap:
725
        if actionsMap:
720
            for k,v in actionsMap.iteritems():
726
            for k,v in actionsMap.iteritems():
721
                tmp_deal = get_mongo_connection().Catalog.Deals.find_one({'_id':k})
727
                tmp_deal = get_mongo_connection().Catalog.Deals.find_one({'_id':k})
722
                print tmp_deal
728
                if tmp_deal is None:
723
                if tmp_deal is None and tmp_deal['category_id']!=6 and (tmp_deal['showDeal']!=1 or tmp_deal['prepaidDeal']!=1) :
729
                    v['rank'] = None
724
                    print "Continue"
730
                    continue
-
 
731
                if tmp_deal['category_id']!=6 and (tmp_deal['showDeal']!=1 or tmp_deal['prepaidDeal']!=1) :
725
                    v['rank'] = None
732
                    v['rank'] = None
726
                    continue
733
                    continue
727
                if v['action'] ==0:
734
                if v['action'] ==0:
728
                    leastDealRankPoints = list(get_mongo_connection().Catalog.Deals.find({'subCategoryId':tmp_deal.get('subCategoryId')}).sort([('dealRankPoints',pymongo.ASCENDING)]).limit(1))
735
                    leastDealRankPoints = list(get_mongo_connection().Catalog.Deals.find({'subCategoryId':tmp_deal.get('subCategoryId')}).sort([('dealRankPoints',pymongo.ASCENDING)]).limit(1))
729
                    if len(leastDealRankPoints) == 0 or leastDealRankPoints[0].get('dealRankPoints') is None:
736
                    if len(leastDealRankPoints) == 0 or leastDealRankPoints[0].get('dealRankPoints') is None: