Subversion Repositories SmartDukaan

Rev

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

Rev 17629 Rev 17654
Line 2243... Line 2243...
2243
    try:
2243
    try:
2244
        get_mongo_connection().Catalog.FeaturedDealsDealObject.remove({'_id':id})
2244
        get_mongo_connection().Catalog.FeaturedDealsDealObject.remove({'_id':id})
2245
        return {1:"Deal Object deleted"}
2245
        return {1:"Deal Object deleted"}
2246
    except:
2246
    except:
2247
        return {0:"Error in deleting object"}
2247
        return {0:"Error in deleting object"}
-
 
2248
    
-
 
2249
def getSubCategoryForFilter(category_id):
-
 
2250
    if mc.get("subCategoryFilter") is None:
-
 
2251
        print "Populating subcategory data for category_id %d" %(category_id)
-
 
2252
        tabData, mobData, accData = [], [], []
-
 
2253
        
-
 
2254
        accessoriesDeals = get_mongo_connection().Catalog.Deals.aggregate([
-
 
2255
                                                                      {"$match":{"category_id":6,"showDeal":1,"totalPoints":{"$gt":-100}}
-
 
2256
                                                                    },
-
 
2257
                                                                 {"$group" : 
-
 
2258
                                                                  {'_id':{'subCategoryId':'$subCategoryId','subCategory':'$subCategory'},'count':{'$sum':1}}
-
 
2259
                                                                  }
-
 
2260
                                                                ])
-
 
2261
        
-
 
2262
        for accessoryDeal in accessoriesDeals['result']:
-
 
2263
            if accessoryDeal.get('_id').get('subCategoryId') != 0:
-
 
2264
                tempMap = {}
-
 
2265
                tempMap['subCategory'] = accessoryDeal.get('_id').get('subCategory')
-
 
2266
                tempMap['subCategoryId'] = accessoryDeal.get('_id').get('subCategoryId')
-
 
2267
                tempMap['count'] = accessoryDeal.get('count')
-
 
2268
                accData.append(tempMap)
-
 
2269
        
-
 
2270
        
-
 
2271
        mc.set("subCategoryFilter",{3:mobData, 5:tabData, 6:accData}, 600)  
-
 
2272
    
-
 
2273
    return sorted(mc.get("subCategoryFilter").get(category_id), key = lambda x: (-x['count'], x['subCategory']))
2248
 
2274
 
2249
 
2275
 
2250
def main():
2276
def main():
2251
    featuredDeals = mc.get("featured_deals")
2277
    featuredDeals = mc.get("featured_deals")
2252
    print resetCache("47")
2278
    print resetCache("47")