Subversion Repositories SmartDukaan

Rev

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

Rev 15130 Rev 15139
Line 625... Line 625...
625
    if source_id in (1,2,4,5):
625
    if source_id in (1,2,4,5):
626
        skuData = list(get_mongo_connection().Catalog.MasterData.find({'identifier':identifier.strip(), 'source_id':source_id}))
626
        skuData = list(get_mongo_connection().Catalog.MasterData.find({'identifier':identifier.strip(), 'source_id':source_id}))
627
    elif source_id == 3:
627
    elif source_id == 3:
628
        skuData = list(get_mongo_connection().Catalog.MasterData.find({'secondaryIdentifier':identifier.strip(), 'source_id':source_id}))
628
        skuData = list(get_mongo_connection().Catalog.MasterData.find({'secondaryIdentifier':identifier.strip(), 'source_id':source_id}))
629
    else:
629
    else:
630
        return {0,'No product found'}
630
        return {0:'No product found'}
631
    user_specific_deals = mc.get(str(userId))
631
    user_specific_deals = mc.get(str(userId))
632
    if user_specific_deals is None:
632
    if user_specific_deals is None:
633
        __populateCache(userId)
633
        __populateCache(userId)
634
        user_specific_deals = mc.get(str(userId))
634
        user_specific_deals = mc.get(str(userId))
635
    else:
635
    else:
636
        print "Getting user deals from cache"
636
        print "Getting user deals from cache"
637
    category_id = skuData[0]['category_id']
637
    category_id = skuData[0]['category_id']
638
    category_specific_deals = user_specific_deals.get(category_id)
638
    category_specific_deals = user_specific_deals.get(category_id)
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['_id'] == skuData[0]['_id']:
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
    
650
 
650
 
651
def getCashBackDetails(identifier, source_id):
651
def getCashBackDetails(identifier, source_id):
652
    if not bool(mc.get("category_cash_back")):
652
    if not bool(mc.get("category_cash_back")):
653
        populateCashBack()
653
        populateCashBack()