Subversion Repositories SmartDukaan

Rev

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

Rev 17944 Rev 17981
Line 358... Line 358...
358
        featuredDeals = mc.get("featured_deals")
358
        featuredDeals = mc.get("featured_deals")
359
            
359
            
360
    except Exception as e:
360
    except Exception as e:
361
        print traceback.print_exc()
361
        print traceback.print_exc()
362
        featuredDeals = {3:{},5:{},6:{}}
362
        featuredDeals = {3:{},5:{},6:{}}
363
    print featuredDeals
-
 
364
    
363
    
365
    fd_bundles = []
364
    fd_bundles = []
366
    
365
    
367
    for catMap in featuredDeals.itervalues():
366
    for catMap in featuredDeals.itervalues():
368
        for fd_map in catMap.itervalues():
367
        for fd_map in catMap.itervalues():
Line 453... Line 452...
453
    tablet_deals = sorted(tablet_deals, key = lambda x: (x['persPoints'],x['totalPoints'],x['bestSellerPoints'], x['nlcPoints'], x['rank']),reverse=True)
452
    tablet_deals = sorted(tablet_deals, key = lambda x: (x['persPoints'],x['totalPoints'],x['bestSellerPoints'], x['nlcPoints'], x['rank']),reverse=True)
454
    accessories_deals = sorted(accessories_deals, key = lambda x: (x['persPoints'],x['totalPoints'],x['bestSellerPoints'], x['nlcPoints'], x['rank']),reverse=True)
453
    accessories_deals = sorted(accessories_deals, key = lambda x: (x['persPoints'],x['totalPoints'],x['bestSellerPoints'], x['nlcPoints'], x['rank']),reverse=True)
455
    
454
    
456
    
455
    
457
    if len(fd_bundles) > 0:
456
    if len(fd_bundles) > 0:
458
        print fd_bundles
-
 
459
        print "There is still bundle in feature deals with points less than -100.Lets add info"
457
        print "There is still bundle in feature deals with points less than -100.Lets add info"
460
        for skuBundleId in fd_bundles:
458
        for skuBundleId in fd_bundles:
461
            dummyDealObjList = __constructDummyDealObject(skuBundleId)
459
            dummyDealObjList = __constructDummyDealObject(skuBundleId)
462
            for dummyDealObj in dummyDealObjList:
460
            for dummyDealObj in dummyDealObjList:
463
                if dummyDealObj['category_id'] ==3:
461
                if dummyDealObj['category_id'] ==3:
Line 502... Line 500...
502
    
500
    
503
    for sorted_deal in mobile_deals:
501
    for sorted_deal in mobile_deals:
504
       
502
       
505
        while(True):
503
        while(True):
506
            if rankMobiles in blockedRanksMobiles:
504
            if rankMobiles in blockedRanksMobiles:
507
                print "skipping rank ",rankMobiles
-
 
508
                rankMobiles = rankMobiles +1
505
                rankMobiles = rankMobiles +1
509
            else:
506
            else:
510
                break
507
                break
511
             
508
             
512
        if sorted_deal['skuBundleId'] in blockedSkuBundlesMobiles:
509
        if sorted_deal['skuBundleId'] in blockedSkuBundlesMobiles:
513
            print "Yes sorted deal in blocked ",sorted_deal['skuBundleId']
-
 
514
            if blockedInfoMobiles.has_key(sorted_deal['skuBundleId']):
510
            if blockedInfoMobiles.has_key(sorted_deal['skuBundleId']):
515
                blockedInfoMobiles.get(sorted_deal['skuBundleId']).append(sorted_deal)
511
                blockedInfoMobiles.get(sorted_deal['skuBundleId']).append(sorted_deal)
516
            else:
512
            else:
517
                blockedInfoMobiles[sorted_deal['skuBundleId']] = [sorted_deal]
513
                blockedInfoMobiles[sorted_deal['skuBundleId']] = [sorted_deal]
518
            continue
514
            continue
Line 528... Line 524...
528
    
524
    
529
            
525
            
530
    for rank in blockedRanksMobiles:
526
    for rank in blockedRanksMobiles:
531
        if blockedInfoMobiles.get((featuredDealsMobiles.get(rank+1)).get('skuBundleId')) is not None:
527
        if blockedInfoMobiles.get((featuredDealsMobiles.get(rank+1)).get('skuBundleId')) is not None:
532
            rankMapMobiles[rank] = blockedInfoMobiles.get((featuredDealsMobiles.get(rank+1)).get('skuBundleId'))
528
            rankMapMobiles[rank] = blockedInfoMobiles.get((featuredDealsMobiles.get(rank+1)).get('skuBundleId'))
533
            print rankMapMobiles[rank]
-
 
534
        
529
        
535
    
530
    
536
    sortedMapTablets = {}
531
    sortedMapTablets = {}
537
    rankMapTablets = {}
532
    rankMapTablets = {}
538
    rankTablets = 0
533
    rankTablets = 0
Line 550... Line 545...
550
    
545
    
551
    
546
    
552
    for sorted_deal in tablet_deals:
547
    for sorted_deal in tablet_deals:
553
        while(True):
548
        while(True):
554
            if rankTablets in blockedRanksTablets:
549
            if rankTablets in blockedRanksTablets:
555
                print "skipping rank ",rankTablets
-
 
556
                rankTablets = rankTablets +1
550
                rankTablets = rankTablets +1
557
            else:
551
            else:
558
                break
552
                break
559
             
553
             
560
        if sorted_deal['skuBundleId'] in blockedSkuBundlesTablets:
554
        if sorted_deal['skuBundleId'] in blockedSkuBundlesTablets:
Line 574... Line 568...
574
            rankMapTablets[(sortedMapTablets.get(sorted_deal['skuBundleId']).keys())[0]] = temp_list
568
            rankMapTablets[(sortedMapTablets.get(sorted_deal['skuBundleId']).keys())[0]] = temp_list
575
            
569
            
576
    for rank in blockedRanksTablets:
570
    for rank in blockedRanksTablets:
577
        if blockedInfoTablets.get((featuredDealsTablets.get(rank+1)).get('skuBundleId')) is not None:
571
        if blockedInfoTablets.get((featuredDealsTablets.get(rank+1)).get('skuBundleId')) is not None:
578
            rankMapTablets[rank] = blockedInfoTablets.get((featuredDealsTablets.get(rank+1)).get('skuBundleId'))
572
            rankMapTablets[rank] = blockedInfoTablets.get((featuredDealsTablets.get(rank+1)).get('skuBundleId'))
579
            print rankMapTablets[rank]
-
 
580
            
573
            
581
    
574
    
582
    sortedMapAccessories = {}
575
    sortedMapAccessories = {}
583
    rankMapAccessories = {}
576
    rankMapAccessories = {}
584
    rankAccessories = 0
577
    rankAccessories = 0
Line 596... Line 589...
596
    
589
    
597
    for sorted_deal in accessories_deals:
590
    for sorted_deal in accessories_deals:
598
       
591
       
599
        while(True):
592
        while(True):
600
            if rankAccessories in blockedRanksAccessories:
593
            if rankAccessories in blockedRanksAccessories:
601
                print "skipping rank ",rankAccessories
-
 
602
                rankAccessories = rankAccessories +1
594
                rankAccessories = rankAccessories +1
603
            else:
595
            else:
604
                break
596
                break
605
             
597
             
606
        if sorted_deal['skuBundleId'] in blockedSkuBundlesAccessories:
598
        if sorted_deal['skuBundleId'] in blockedSkuBundlesAccessories:
607
            print "Yes sorted deal in blocked ",sorted_deal['skuBundleId']
-
 
608
            if blockedInfoAccessories.has_key(sorted_deal['skuBundleId']):
599
            if blockedInfoAccessories.has_key(sorted_deal['skuBundleId']):
609
                blockedInfoAccessories.get(sorted_deal['skuBundleId']).append(sorted_deal)
600
                blockedInfoAccessories.get(sorted_deal['skuBundleId']).append(sorted_deal)
610
            else:
601
            else:
611
                blockedInfoAccessories[sorted_deal['skuBundleId']] = [sorted_deal]
602
                blockedInfoAccessories[sorted_deal['skuBundleId']] = [sorted_deal]
612
            continue
603
            continue
Line 620... Line 611...
620
                temp_list.append(sorted_deal)
611
                temp_list.append(sorted_deal)
621
            rankMapAccessories[(sortedMapAccessories.get(sorted_deal['skuBundleId']).keys())[0]] = temp_list
612
            rankMapAccessories[(sortedMapAccessories.get(sorted_deal['skuBundleId']).keys())[0]] = temp_list
622
    
613
    
623
            
614
            
624
    for rank in blockedRanksAccessories:
615
    for rank in blockedRanksAccessories:
625
        print "Adding rank acc ",rank 
-
 
626
        if blockedInfoAccessories.get((featuredDealsAccessories.get(rank+1)).get('skuBundleId')) is not None:
616
        if blockedInfoAccessories.get((featuredDealsAccessories.get(rank+1)).get('skuBundleId')) is not None:
627
            rankMapAccessories[rank] = blockedInfoAccessories.get((featuredDealsAccessories.get(rank+1)).get('skuBundleId'))
617
            rankMapAccessories[rank] = blockedInfoAccessories.get((featuredDealsAccessories.get(rank+1)).get('skuBundleId'))
628
            print rankMapAccessories[rank]
-
 
629
    
618
    
630
    print rankMapAccessories
-
 
631
    
619
    
632
    mem_cache_val = {3:mobile_deals, 5:tablet_deals, 6: accessories_deals,"3_rankMap": rankMapMobiles,"5_rankMap": rankMapTablets,"6_rankMap": rankMapAccessories }
620
    mem_cache_val = {3:mobile_deals, 5:tablet_deals, 6: accessories_deals,"3_rankMap": rankMapMobiles,"5_rankMap": rankMapTablets,"6_rankMap": rankMapAccessories }
633
    mc.set(str(userId), mem_cache_val)
621
    mc.set(str(userId), mem_cache_val)
634
    
622
    
635
 
623
 
Line 781... Line 769...
781
                else:
769
                else:
782
                    break
770
                    break
783
            
771
            
784
        temp = []
772
        temp = []
785
        if dealList is None or len(dealList)==0:
773
        if dealList is None or len(dealList)==0:
786
            print "Empty deal;lisr"
-
 
787
            continue
774
            continue
788
        for d in dealList:
775
        for d in dealList:
789
            item = list(get_mongo_connection().Catalog.MasterData.find({'_id':d['_id']}))
776
            item = list(get_mongo_connection().Catalog.MasterData.find({'_id':d['_id']}))
790
            if len(item) ==0:
777
            if len(item) ==0:
791
                continue
778
                continue
Line 1179... Line 1166...
1179
        return {1:'Cache cleared.'}
1166
        return {1:'Cache cleared.'}
1180
    except:
1167
    except:
1181
        return {0:'Unable to clear cache.'}
1168
        return {0:'Unable to clear cache.'}
1182
    
1169
    
1183
def updateCollection(data):
1170
def updateCollection(data):
1184
    print data
-
 
1185
    try:
1171
    try:
1186
        collection = get_mongo_connection().Catalog[data['class']]
1172
        collection = get_mongo_connection().Catalog[data['class']]
1187
        class_name = data.pop('class')
1173
        class_name = data.pop('class')
1188
        _id = data.pop('oid')
1174
        _id = data.pop('oid')
1189
        result = collection.update({'_id':ObjectId(_id)},{"$set":data},upsert=False, multi = False)
1175
        result = collection.update({'_id':ObjectId(_id)},{"$set":data},upsert=False, multi = False)
Line 2476... Line 2462...
2476
    result =  get_elastic_search_connection().search(index="my_index", body=payload)
2462
    result =  get_elastic_search_connection().search(index="my_index", body=payload)
2477
    totalCount= result['hits']['total']
2463
    totalCount= result['hits']['total']
2478
    return {'searchTerm':searchTerm,'count':totalCount}
2464
    return {'searchTerm':searchTerm,'count':totalCount}
2479
            
2465
            
2480
def main():
2466
def main():
2481
    import time
-
 
2482
    for i in range(0,10):
-
 
2483
        result = getCountForSearchText(20, "iph")
2467
    print getSubCategoryForFilter(6)
2484
        print result
-
 
2485
        time.sleep(20)
-
 
2486
    
2468
    
2487
if __name__=='__main__':
2469
if __name__=='__main__':
2488
    main()
2470
    main()
2489
 
2471
 
2490
 
2472