Subversion Repositories SmartDukaan

Rev

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

Rev 22240 Rev 22256
Line 50... Line 50...
50
elastic_search_port = config_client.get_property('elastic_search_port')
50
elastic_search_port = config_client.get_property('elastic_search_port')
51
 
51
 
52
 
52
 
53
 
53
 
54
SOURCE_MAP = {1:'AMAZON',2:'FLIPKART',3:'SNAPDEAL',4:'SAHOLIC',5:"SHOPCLUES.COM",6:"PAYTM.COM",7:"HOMESHOP18.COM"}
54
SOURCE_MAP = {1:'AMAZON',2:'FLIPKART',3:'SNAPDEAL',4:'SAHOLIC',5:"SHOPCLUES.COM",6:"PAYTM.COM",7:"HOMESHOP18.COM"}
-
 
55
ONLINE_DEAL_SOURCE_MAP = {1:'AMAZON',2:'FLIPKART',3:'SNAPDEAL',5:"SHOPCLUES.COM",6:"PAYTM.COM",7:"HOMESHOP18.COM"}
55
 
56
 
56
COLLECTION_MAP = {
57
COLLECTION_MAP = {
57
                  'ExceptionalNlc':'skuBundleId',
58
                  'ExceptionalNlc':'skuBundleId',
58
                  'SkuDealerPrices':'skuBundleId',
59
                  'SkuDealerPrices':'skuBundleId',
59
                  'SkuDiscountInfo':'skuBundleId',
60
                  'SkuDiscountInfo':'skuBundleId',
Line 908... Line 909...
908
            elif f_deal['category_id']==6:
909
            elif f_deal['category_id']==6:
909
                featuredDealObjectAccessories[rank] = f_deal
910
                featuredDealObjectAccessories[rank] = f_deal
910
    mc.set("featured_deals_deal_object", {3:featuredDealObjectMobiles,5:featuredDealObjectTablets,6:featuredDealObjectAccessories}, 600)
911
    mc.set("featured_deals_deal_object", {3:featuredDealObjectMobiles,5:featuredDealObjectTablets,6:featuredDealObjectAccessories}, 600)
911
    print mc.get('featured_deals_deal_object')
912
    print mc.get('featured_deals_deal_object')
912
 
913
 
-
 
914
#introducing online/deals with fofo flag
913
def getNewDeals(userId, category_id, offset, limit, sort, direction, filterData=None):
915
def getNewDeals(userId, category_id, offset, limit, sort, direction, filterData=None, source=None, tag_ids=None):
914
    if mc.get("category_cash_back") is None or not bool(mc.get("category_cash_back")):
916
    if mc.get("category_cash_back") is None or not bool(mc.get("category_cash_back")):
915
        populateCashBack()
917
        populateCashBack()
916
    
918
    
917
    dealsListMap = []
919
    dealsListMap = []
918
    user_specific_deals = mc.get(str(userId))
920
    user_specific_deals = mc.get(str(userId))
Line 920... Line 922...
920
        __populateCache(userId)
922
        __populateCache(userId)
921
        user_specific_deals = mc.get(str(userId))
923
        user_specific_deals = mc.get(str(userId))
922
    else:
924
    else:
923
        print "Getting user deals from cache"
925
        print "Getting user deals from cache"
924
    category_specific_deals = user_specific_deals.get(category_id)
926
    category_specific_deals = user_specific_deals.get(category_id)
-
 
927
    #filter categores on basis of source and tags
-
 
928
    if source=="online":
-
 
929
        category_specific_deals = filter(lambda x: x['souce_id'] in ONLINE_DEAL_SOURCE_MAP, category_specific_deals)
-
 
930
    elif source=="deals":
-
 
931
        category_specific_deals = filter(lambda x: x['souce_id'] == SOURCE_MAP.get("SAHOLIC"), category_specific_deals)
-
 
932
        
-
 
933
         
925
    
934
    
926
    insert_featured_deals = False
935
    insert_featured_deals = False
927
    if sort is None or direction is None:
936
    if sort is None or direction is None:
928
        insert_featured_deals = True
937
        insert_featured_deals = True
929
        rankMap = user_specific_deals.get(str(category_id)+"_rankMap")
938
        rankMap = user_specific_deals.get(str(category_id)+"_rankMap")
Line 1100... Line 1109...
1100
                if item[0]['source_id']==4:
1109
                if item[0]['source_id']==4:
1101
                    item_availability_info = mc.get("item_availability_"+str(item[0]['identifier']).strip())
1110
                    item_availability_info = mc.get("item_availability_"+str(item[0]['identifier']).strip())
1102
                    if item_availability_info is None or len(item_availability_info)==0:
1111
                    if item_availability_info is None or len(item_availability_info)==0:
1103
                        item[0]['availabilityInfo'] = [{}]
1112
                        item[0]['availabilityInfo'] = [{}]
1104
                    else:
1113
                    else:
-
 
1114
                        #remove items that are mapped with tag_ids recieved
-
 
1115
                        if tag_ids:
-
 
1116
                            #construct item_availability_info TAGS not matched 
-
 
1117
                            item_availability_info = [av_info for av_info in item_availability_info if not (av_info.has_key('tag_ids') and not set(tag_ids).isdisjoint(av_info.get('tag_ids')))]
-
 
1118
                            if len(item_availability_info)==0:
-
 
1119
                                item_availability_info = [{}]
1105
                        item[0]['availabilityInfo'] = item_availability_info
1120
                        item[0]['availabilityInfo'] = item_availability_info
1106
            except:
1121
            except:
1107
                item[0]['availabilityInfo'] = [{}]
1122
                item[0]['availabilityInfo'] = [{}]
1108
            
1123
            
1109
            if item[0]['source_id']==4:
1124
            if item[0]['source_id']==4:
Line 1149... Line 1164...
1149
            temp = sorted(temp, key = lambda x: (x['available_price']),reverse=False)
1164
            temp = sorted(temp, key = lambda x: (x['available_price']),reverse=False)
1150
        dealsListMap.append(temp)
1165
        dealsListMap.append(temp)
1151
    return dealsListMap
1166
    return dealsListMap
1152
 
1167
 
1153
 
1168
 
1154
def getAccesoryDeals(userId, category_id, offset, limit, sort, direction, filterData=None):
1169
def getAccesoryDeals(userId, category_id, offset, limit, sort, direction, filterData=None, source="all", tag_ids=None):
1155
    if mc.get("category_cash_back") is None or not bool(mc.get("category_cash_back")):
1170
    if mc.get("category_cash_back") is None or not bool(mc.get("category_cash_back")):
1156
        populateCashBack()
1171
        populateCashBack()
1157
    
1172
    
1158
    dealsListMap = []
1173
    dealsListMap = []
1159
    user_specific_deals = mc.get(str(userId)+'_acc')
1174
    user_specific_deals = mc.get(str(userId)+'_acc')
Line 1162... Line 1177...
1162
        user_specific_deals = mc.get(str(userId)+'_acc')
1177
        user_specific_deals = mc.get(str(userId)+'_acc')
1163
    else:
1178
    else:
1164
        print "Getting user deals from accessory cache"
1179
        print "Getting user deals from accessory cache"
1165
    category_specific_deals = user_specific_deals.get(category_id)
1180
    category_specific_deals = user_specific_deals.get(category_id)
1166
    
1181
    
-
 
1182
    #filter categores on basis of source and tags
-
 
1183
    if source=="online":
-
 
1184
        category_specific_deals = filter(lambda x: x['souce_id'] in ONLINE_DEAL_SOURCE_MAP, category_specific_deals)
-
 
1185
    elif source=="deals":
-
 
1186
        category_specific_deals = filter(lambda x: x['souce_id'] == SOURCE_MAP.get("SAHOLIC"), category_specific_deals)
-
 
1187
    
1167
    insert_featured_deals = False
1188
    insert_featured_deals = False
1168
    if sort is None or direction is None:
1189
    if sort is None or direction is None:
1169
        insert_featured_deals = True
1190
        insert_featured_deals = True
1170
        rankMap = user_specific_deals.get(str(category_id)+"_rankMap")
1191
        rankMap = user_specific_deals.get(str(category_id)+"_rankMap")
1171
    else:
1192
    else:
Line 1341... Line 1362...
1341
                if item[0]['source_id']==4:
1362
                if item[0]['source_id']==4:
1342
                    item_availability_info = mc.get("item_availability_"+str(item[0]['identifier']).strip())
1363
                    item_availability_info = mc.get("item_availability_"+str(item[0]['identifier']).strip())
1343
                    if item_availability_info is None or len(item_availability_info)==0:
1364
                    if item_availability_info is None or len(item_availability_info)==0:
1344
                        item[0]['availabilityInfo'] = [{}]
1365
                        item[0]['availabilityInfo'] = [{}]
1345
                    else:
1366
                    else:
-
 
1367
                        #remove items that are mapped with tag_ids recieved
-
 
1368
                        if tag_ids:
-
 
1369
                            #construct item_availability_info TAGS not matched 
-
 
1370
                            item_availability_info = [av_info for av_info in item_availability_info if not (av_info.has_key('tag_ids') and not set(tag_ids).isdisjoint(av_info.get('tag_ids')))]
-
 
1371
                            if len(item_availability_info)==0:
-
 
1372
                                item_availability_info = [{}]
1346
                        item[0]['availabilityInfo'] = item_availability_info
1373
                        item[0]['availabilityInfo'] = item_availability_info
1347
            except:
1374
            except:
1348
                item[0]['availabilityInfo'] = [{}]
1375
                item[0]['availabilityInfo'] = [{}]
1349
            
1376
            
1350
            if item[0]['source_id']==4:
1377
            if item[0]['source_id']==4: