Subversion Repositories SmartDukaan

Rev

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

Rev 19583 Rev 19596
Line 402... Line 402...
402
    outer_query.append({'totalPoints':query})
402
    outer_query.append({'totalPoints':query})
403
    outer_query.append({'category_id':{"$in":[3,5]}})
403
    outer_query.append({'category_id':{"$in":[3,5]}})
404
    brandPrefMap = {}
404
    brandPrefMap = {}
405
    pricePrefMap = {}
405
    pricePrefMap = {}
406
    actionsMap = {}
406
    actionsMap = {}
-
 
407
    try:
407
    brand_p = session.query(price_preferences).filter_by(user_id=userId).all()
408
        brand_p = session.query(price_preferences).filter_by(user_id=userId).all()
408
    for x in brand_p:
409
        for x in brand_p:
409
        pricePrefMap[x.category_id] = [x.min_price,x.max_price]
410
            pricePrefMap[x.category_id] = [x.min_price,x.max_price]
410
    for x in session.query(brand_preferences).filter_by(user_id=userId).all():
411
        for x in session.query(brand_preferences).filter_by(user_id=userId).all():
411
        temp_map = {}
412
            temp_map = {}
412
        if brandPrefMap.has_key((x.brand).strip().upper()):
413
            if brandPrefMap.has_key((x.brand).strip().upper()):
413
            val = brandPrefMap.get((x.brand).strip().upper())
414
                val = brandPrefMap.get((x.brand).strip().upper())
414
            temp_map[x.category_id] = 1 if x.status == 'show' else 0
415
                temp_map[x.category_id] = 1 if x.status == 'show' else 0
415
            val.append(temp_map)
416
                val.append(temp_map)
416
        else:
417
            else:
417
            temp = []
418
                temp = []
418
            temp_map[x.category_id] = 1 if x.status == 'show' else 0
419
                temp_map[x.category_id] = 1 if x.status == 'show' else 0
419
            temp.append(temp_map)
420
                temp.append(temp_map)
420
            brandPrefMap[(x.brand).strip().upper()] = temp
421
                brandPrefMap[(x.brand).strip().upper()] = temp
421
            
422
                
422
    for x in session.query(user_actions).filter_by(user_id=userId).all():
423
        for x in session.query(user_actions).filter_by(user_id=userId).all():
423
        actionsMap[x.store_product_id] = 1 if x.action == 'like' else 0
424
            actionsMap[x.store_product_id] = 1 if x.action == 'like' else 0
-
 
425
    except:
424
        
426
        pass
-
 
427
    finally:
425
    session.close()
428
        session.close()
426
    
429
    
427
    all_deals = list(get_mongo_connection().Catalog.Deals.find({"$and":outer_query},{'_id':1,'category_id':1,'brand':1,'totalPoints':1,'bestSellerPoints':1,'nlcPoints':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([('totalPoints',pymongo.DESCENDING),('bestSellerPoints',pymongo.DESCENDING),('nlcPoints',pymongo.DESCENDING),('rank',pymongo.DESCENDING)]))
430
    all_deals = list(get_mongo_connection().Catalog.Deals.find({"$and":outer_query},{'_id':1,'category_id':1,'brand':1,'totalPoints':1,'bestSellerPoints':1,'nlcPoints':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([('totalPoints',pymongo.DESCENDING),('bestSellerPoints',pymongo.DESCENDING),('nlcPoints',pymongo.DESCENDING),('rank',pymongo.DESCENDING)]))
428
    mobile_deals = []
431
    mobile_deals = []
429
    tablet_deals = []
432
    tablet_deals = []
430
    #accessories_deals = []
433
    #accessories_deals = []
Line 694... Line 697...
694
 
697
 
695
    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)]))
698
    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)]))
696
    
699
    
697
    actionsMap = {}
700
    actionsMap = {}
698
    actionRank = 3
701
    actionRank = 3
-
 
702
    try:
699
    for x in session.query(user_actions).filter_by(user_id=userId).order_by(asc(user_actions.created)).all():
703
        for x in session.query(user_actions).filter_by(user_id=userId).order_by(asc(user_actions.created)).all():
700
        action = 1 if x.action == 'like' else 0
704
            action = 1 if x.action == 'like' else 0
701
        if action==1:
705
            if action==1:
702
            actionsMap[x.store_product_id] = {'action':action,'rank':actionRank,'dealRankPoints':None}
706
                actionsMap[x.store_product_id] = {'action':action,'rank':actionRank,'dealRankPoints':None}
703
            actionRank = actionRank+3
707
                actionRank = actionRank+3
704
        else:
708
            else:
705
            actionsMap[x.store_product_id] = {'action':action,'rank':None,'dealRankPoints':None}
709
                actionsMap[x.store_product_id] = {'action':action,'rank':None,'dealRankPoints':None}
706
    
710
    except:
-
 
711
        pass
-
 
712
    finally:    
707
    session.close()
713
        session.close()
708
    
714
    
709
    pseudo_count = 1
715
    pseudo_count = 1
710
    inserted_count = 0
716
    inserted_count = 0
711
    try:
717
    try:
712
        if actionsMap:
718
        if actionsMap: