Subversion Repositories SmartDukaan

Rev

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

Rev 15151 Rev 15345
Line 359... Line 359...
359
            temp.append(temp_map)
359
            temp.append(temp_map)
360
            brandPrefMap[(x.brand).strip().upper()] = temp
360
            brandPrefMap[(x.brand).strip().upper()] = temp
361
        
361
        
362
    for x in session.query(user_actions).filter_by(user_id=userId).all():
362
    for x in session.query(user_actions).filter_by(user_id=userId).all():
363
        actionsMap[x.store_product_id] = 1 if x.action == 'like' else 0
363
        actionsMap[x.store_product_id] = 1 if x.action == 'like' else 0
364
    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}).sort([('totalPoints',pymongo.DESCENDING),('bestSellerPoints',pymongo.DESCENDING),('nlcPoints',pymongo.DESCENDING),('rank',pymongo.DESCENDING)]))
364
    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}).sort([('totalPoints',pymongo.DESCENDING),('bestSellerPoints',pymongo.DESCENDING),('nlcPoints',pymongo.DESCENDING),('rank',pymongo.DESCENDING)]))
365
    all_category_deals = []
365
    all_category_deals = []
366
    mobile_deals = []
366
    mobile_deals = []
367
    tablet_deals = []
367
    tablet_deals = []
368
    for deal in all_deals:
368
    for deal in all_deals:
369
        if actionsMap.get(deal['_id']) == 0:
369
        if actionsMap.get(deal['_id']) == 0:
Line 639... Line 639...
639
    if category_specific_deals is None or len(category_specific_deals) ==0:
639
    if category_specific_deals is None or len(category_specific_deals) ==0:
640
        return {0:'Category specific deals is empty'}
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)
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
642
    rank = 1
643
    for sorted_deal in sorted_deals:
643
    for sorted_deal in sorted_deals:
644
        if sorted_deal['_id'] == skuData[0]['_id']:
644
        if sorted_deal['skuBundleId'] == skuData[0]['skuBundleId']:
645
            return {rank:'Rank found'}
645
            return {rank:'Rank found'}
646
            break 
646
            break 
647
        rank+=1
647
        rank+=1
648
    return {0:'Rank not found'}
648
    return {0:'Rank not found'}
649
    
649