Subversion Repositories SmartDukaan

Rev

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

Rev 16067 Rev 16079
Line 404... Line 404...
404
            __populateFeaturedDeals()
404
            __populateFeaturedDeals()
405
    except:
405
    except:
406
        pass 
406
        pass 
407
    
407
    
408
    rank = 1
408
    rank = 1
409
    dealsMap = {}
409
    dealsListMap = []
410
    user_specific_deals = mc.get(str(userId))
410
    user_specific_deals = mc.get(str(userId))
411
    if user_specific_deals is None:
411
    if user_specific_deals is None:
412
        __populateCache(userId)
412
        __populateCache(userId)
413
        user_specific_deals = mc.get(str(userId))
413
        user_specific_deals = mc.get(str(userId))
414
    else:
414
    else:
Line 445... Line 445...
445
            rankMap[rank] = (sortedMap[sorted_deal['skuBundleId']].values())[0]
445
            rankMap[rank] = (sortedMap[sorted_deal['skuBundleId']].values())[0]
446
            rank = rank +1
446
            rank = rank +1
447
        else:
447
        else:
448
            for temp_list in sortedMap.get(sorted_deal['skuBundleId']).itervalues():
448
            for temp_list in sortedMap.get(sorted_deal['skuBundleId']).itervalues():
449
                temp_list.append(sorted_deal)
449
                temp_list.append(sorted_deal)
450
            rankMap[(sortedMap.get(sorted_deal['skuBundleId']).keys())[0]] = temp_list 
450
            rankMap[(sortedMap.get(sorted_deal['skuBundleId']).keys())[0]] = temp_list
451
                
451
                
452
    for dealList in [rankMap.get(k, []) for k in range(offset, offset+limit)]:
452
    for dealList in [rankMap.get(k, []) for k in range(offset, offset+limit)]:
-
 
453
        temp = []
453
        for d in dealList:
454
        for d in dealList:
454
            item = list(get_mongo_connection().Catalog.MasterData.find({'_id':d['_id']}))
455
            item = list(get_mongo_connection().Catalog.MasterData.find({'_id':d['_id']}))
455
            if not dealsMap.has_key(item[0]['identifier']):
-
 
456
                item[0]['dealRank'] = rank
-
 
457
                item[0]['persPoints'] = d['persPoints']
456
            item[0]['persPoints'] = d['persPoints']
458
                if d['dealType'] == 1 and d['source_id'] ==1:
457
            if d['dealType'] == 1 and d['source_id'] ==1:
459
                    item[0]['marketPlaceUrl'] = "http://www.amazon.in/dp/%s"%(item[0]['identifier'].strip())
458
                item[0]['marketPlaceUrl'] = "http://www.amazon.in/dp/%s"%(item[0]['identifier'].strip())
460
                elif d['source_id'] ==3:
459
            elif d['source_id'] ==3:
461
                    item[0]['marketPlaceUrl'] = item[0]['marketPlaceUrl']+'?supc='+item[0].get('identifier')
460
                item[0]['marketPlaceUrl'] = item[0]['marketPlaceUrl']+'?supc='+item[0].get('identifier')
462
                else:
461
            else:
463
                    pass 
462
                pass 
464
                try:
463
            try:
465
                    cashBack = getCashBack(item[0]['_id'], item[0]['source_id'], item[0]['category_id'])
464
                cashBack = getCashBack(item[0]['_id'], item[0]['source_id'], item[0]['category_id'])
466
                    if not cashBack or cashBack.get('cash_back_status')!=1:
465
                if not cashBack or cashBack.get('cash_back_status')!=1:
467
                        item[0]['cash_back_type'] = 0
-
 
468
                        item[0]['cash_back'] = 0
-
 
469
                    else:
-
 
470
                        item[0]['cash_back_type'] = int(cashBack['cash_back_type'])
-
 
471
                        item[0]['cash_back'] = cashBack['cash_back']
-
 
472
                except:
-
 
473
                    print "Error in adding cashback to deals"
-
 
474
                    item[0]['cash_back_type'] = 0
466
                    item[0]['cash_back_type'] = 0
475
                    item[0]['cash_back'] = 0
467
                    item[0]['cash_back'] = 0
-
 
468
                else:
-
 
469
                    item[0]['cash_back_type'] = int(cashBack['cash_back_type'])
476
                dealsMap[item[0]['identifier']] = item[0]
470
                    item[0]['cash_back'] = cashBack['cash_back']
477
                
471
            except:
-
 
472
                print "Error in adding cashback to deals"
-
 
473
                item[0]['cash_back_type'] = 0
-
 
474
                item[0]['cash_back'] = 0
478
                rank +=1
475
            temp.append(item[0])
479
    return sorted(dealsMap.values(), key=itemgetter('dealRank'))
476
        dealsListMap.append(temp)
480
 
-
 
-
 
477
    return dealsListMap
481
 
478
 
482
def filterDeals(deals, filterData):
479
def filterDeals(deals, filterData):
483
    dealFiltered = []
480
    dealFiltered = []
484
    brandsFiltered = []
481
    brandsFiltered = []
485
    filterArray = filterData.split('|')
482
    filterArray = filterData.split('|')
Line 1213... Line 1210...
1213
def getItemObjForStaticDeals(item):
1210
def getItemObjForStaticDeals(item):
1214
    return {'marketPlaceUrl':item.get('marketPlaceUrl'),'available_price':item.get('available_price'),'source_product_name':item.get('source_product_name'),'thumbnail':item.get('thumbnail'),'source_id':int(item.get('source_id'))}
1211
    return {'marketPlaceUrl':item.get('marketPlaceUrl'),'available_price':item.get('available_price'),'source_product_name':item.get('source_product_name'),'thumbnail':item.get('thumbnail'),'source_id':int(item.get('source_id'))}
1215
    
1212
    
1216
def main():
1213
def main():
1217
    __populateCache(47)
1214
    __populateCache(47)
1218
    getNewDeals(47, 0, 0, 20, None, None, None)
1215
    for x in getNewDeals(47, 0, 0, 20, None, None, None):
-
 
1216
        print x
1219
    
1217
    
1220
    
1218
    
1221
    
1219
    
1222
if __name__=='__main__':
1220
if __name__=='__main__':
1223
    main()
1221
    main()