Subversion Repositories SmartDukaan

Rev

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

Rev 15041 Rev 15062
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}).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}).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 1132... Line 1132...
1132
                    temp.append(allDeal.get('_id').get('brand_id'))
1132
                    temp.append(allDeal.get('_id').get('brand_id'))
1133
                    brandMap[allDeal.get('_id').get('brand')] = {'brand_ids':temp,'count':allDeal.get('count')}
1133
                    brandMap[allDeal.get('_id').get('brand')] = {'brand_ids':temp,'count':allDeal.get('count')}
1134
      
1134
      
1135
        mc.set("brandFilter",{0:brandMap, 3:mobData, 5:tabData}, 600)  
1135
        mc.set("brandFilter",{0:brandMap, 3:mobData, 5:tabData}, 600)  
1136
    
1136
    
1137
    return sorted(mc.get("brandFilter").get(category_id), key = lambda x: (x['count']),reverse=True)
1137
    return sorted(mc.get("brandFilter").get(category_id), key = lambda x: (-x['count'], x['brand']))
1138
        
1138
        
1139
def main():
1139
def main():
1140
    print (getBrandsForFilter(0))
1140
    print (getBrandsForFilter(0))
1141
    
1141
    
1142
    
1142