Subversion Repositories SmartDukaan

Rev

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

Rev 19596 Rev 19597
Line 384... Line 384...
384
        featuredDeals = {3:{},5:{},6:{}}
384
        featuredDeals = {3:{},5:{},6:{}}
385
    
385
    
386
    
386
    
387
    #Not taking into account accessories
387
    #Not taking into account accessories
388
    featuredDeals.pop(6,None)
388
    featuredDeals.pop(6,None)
-
 
389
    print featuredDeals
389
    
390
    
390
    fd_bundles = []
391
    fd_bundles = []
391
    
392
    
392
    for catMap in featuredDeals.itervalues():
393
    for catMap in featuredDeals.itervalues():
393
        for fd_map in catMap.itervalues():
394
        for fd_map in catMap.itervalues():
Line 1156... Line 1157...
1156
    if sort is None or direction is None:
1157
    if sort is None or direction is None:
1157
        insert_featured_deals = True
1158
        insert_featured_deals = True
1158
        rankMap = user_specific_deals.get(str(category_id)+"_rankMap")
1159
        rankMap = user_specific_deals.get(str(category_id)+"_rankMap")
1159
    else:
1160
    else:
1160
        if sort == "bestSellerPoints":
1161
        if sort == "bestSellerPoints":
1161
            sorted_deals = sorted(category_specific_deals, key = lambda x: (x['bestSellerPoints'], -x['internalRank'], x['nlcPoints']),reverse=True)
1162
            sorted_deals = sorted(category_specific_deals, key = lambda x: (x['bestSellerPoints'], x['dealRankPoints'], x['nlcPoints']),reverse=True)
1162
        else:
1163
        else:
1163
            if direction == -1:
1164
            if direction == -1:
1164
                rev = True
1165
                rev = True
1165
            else:
1166
            else:
1166
                rev = False
1167
                rev = False
Line 2150... Line 2151...
2150
                                                                  {'_id':{'brand_id':'$brand_id','brand':'$brand'},'count':{'$sum':1}}
2151
                                                                  {'_id':{'brand_id':'$brand_id','brand':'$brand'},'count':{'$sum':1}}
2151
                                                                  }
2152
                                                                  }
2152
                                                                ])
2153
                                                                ])
2153
        
2154
        
2154
        accessoriesDeals = get_mongo_connection().Catalog.Deals.aggregate([
2155
        accessoriesDeals = get_mongo_connection().Catalog.Deals.aggregate([
2155
                                                                      {"$match":{"category_id":6,"showDeal":1,"totalPoints":{"$gt":-100}}
2156
                                                                      {"$match":{"category_id":6,"showDeal":1,"dealRankPoints":{"$gt":0}}
2156
                                                                    },
2157
                                                                    },
2157
                                                                 {"$group" : 
2158
                                                                 {"$group" : 
2158
                                                                  {'_id':{'brand_id':'$brand_id','brand':'$brand'},'count':{'$sum':1}}
2159
                                                                  {'_id':{'brand_id':'$brand_id','brand':'$brand'},'count':{'$sum':1}}
2159
                                                                  }
2160
                                                                  }
2160
                                                                ])
2161
                                                                ])
2161
        
2162
        
2162
        allDeals = get_mongo_connection().Catalog.Deals.aggregate([
-
 
2163
                                                                   {"$match":{"showDeal":1,"totalPoints":{"$gt":-100}}
-
 
2164
                                                                    },
-
 
2165
                                                                 {"$group" : 
-
 
2166
                                                                  {'_id':{'brand_id':'$brand_id','brand':'$brand'},'count':{'$sum':1}}
-
 
2167
                                                                  }
-
 
2168
                                                                ])
-
 
2169
        #print mobileDeals
2163
        #print mobileDeals
2170
        #print "==========Mobile data ends=========="
2164
        #print "==========Mobile data ends=========="
2171
        
2165
        
2172
        #print tabletDeals
2166
        #print tabletDeals
2173
        #print "==========Tablet data ends=========="
2167
        #print "==========Tablet data ends=========="
Line 2196... Line 2190...
2196
                tempMap = {}
2190
                tempMap = {}
2197
                tempMap['brand'] = accessoryDeal.get('_id').get('brand')
2191
                tempMap['brand'] = accessoryDeal.get('_id').get('brand')
2198
                tempMap['brand_id'] = accessoryDeal.get('_id').get('brand_id')
2192
                tempMap['brand_id'] = accessoryDeal.get('_id').get('brand_id')
2199
                tempMap['count'] = accessoryDeal.get('count')
2193
                tempMap['count'] = accessoryDeal.get('count')
2200
                accData.append(tempMap)
2194
                accData.append(tempMap)
2201
        
-
 
2202
        
-
 
2203
        brandMap = {}
-
 
2204
        for allDeal in allDeals['result']:
-
 
2205
            if allDeal.get('_id').get('brand_id') != 0:
-
 
2206
                if brandMap.has_key(allDeal.get('_id').get('brand')):
-
 
2207
                    brand_ids = brandMap.get(allDeal.get('_id').get('brand')).get('brand_ids')
-
 
2208
                    brand_ids.append(allDeal.get('_id').get('brand_id'))
-
 
2209
                    brandMap[allDeal.get('_id').get('brand')] = {'brand_ids':brand_ids,'count':brandMap.get(allDeal.get('_id').get('brand')).get('count') + allDeal.get('count')}
-
 
2210
                else:
-
 
2211
                    temp = []
-
 
2212
                    temp.append(allDeal.get('_id').get('brand_id'))
-
 
2213
                    brandMap[allDeal.get('_id').get('brand')] = {'brand_ids':temp,'count':allDeal.get('count')}
-
 
2214
      
2195
      
2215
        mc.set("brandFilter",{0:brandMap, 3:mobData, 5:tabData, 6:accData}, 600)  
2196
        mc.set("brandFilter",{3:mobData, 5:tabData, 6:accData}, 600)  
2216
    
2197
    
2217
    return sorted(mc.get("brandFilter").get(category_id), key = lambda x: (-x['count'], x['brand']))
2198
    return sorted(mc.get("brandFilter").get(category_id), key = lambda x: (-x['count'], x['brand']))
2218
 
2199
 
2219
def getStaticDeals(offset, limit, category_id, direction):
2200
def getStaticDeals(offset, limit, category_id, direction):
2220
    user_specific_deals = mc.get("staticDeals")
2201
    user_specific_deals = mc.get("staticDeals")
Line 2893... Line 2874...
2893
    if mc.get("subCategoryFilter") is None:
2874
    if mc.get("subCategoryFilter") is None:
2894
        print "Populating subcategory data for category_id %d" %(category_id)
2875
        print "Populating subcategory data for category_id %d" %(category_id)
2895
        tabData, mobData, accData = [], [], []
2876
        tabData, mobData, accData = [], [], []
2896
        
2877
        
2897
        accessoriesDeals = get_mongo_connection().Catalog.Deals.aggregate([
2878
        accessoriesDeals = get_mongo_connection().Catalog.Deals.aggregate([
2898
                                                                      {"$match":{"category_id":6,"showDeal":1,"totalPoints":{"$gt":-100}}
2879
                                                                      {"$match":{"category_id":6,"showDeal":1,"dealRankPoints":{"$gt":0}}
2899
                                                                    },
2880
                                                                    },
2900
                                                                 {"$group" : 
2881
                                                                 {"$group" : 
2901
                                                                  {'_id':{'subCategoryId':'$subCategoryId','subCategory':'$subCategory'},'count':{'$sum':1}}
2882
                                                                  {'_id':{'subCategoryId':'$subCategoryId','subCategory':'$subCategory'},'count':{'$sum':1}}
2902
                                                                  }
2883
                                                                  }
2903
                                                                ])
2884
                                                                ])