Subversion Repositories SmartDukaan

Rev

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

Rev 17732 Rev 17733
Line 1694... Line 1694...
1694
    random.shuffle(tablet_deals,random.random)
1694
    random.shuffle(tablet_deals,random.random)
1695
    
1695
    
1696
    mem_cache_val = {3:mobile_deals, 5:tablet_deals}
1696
    mem_cache_val = {3:mobile_deals, 5:tablet_deals}
1697
    mc.set("staticDeals", mem_cache_val, 3600)
1697
    mc.set("staticDeals", mem_cache_val, 3600)
1698
 
1698
 
1699
def getItemObjForStaticDeals(item):
1699
def getItemObjForStaticDeals(item,transform=None):
-
 
1700
    mpu = str(item.get('marketPlaceUrl'))
-
 
1701
    if transform:
-
 
1702
        if mpu.find("snapdeal")!=-1:
-
 
1703
            mpu = "http://m.snapdeal.com"+mpu[mpu.find("/product"):]
-
 
1704
        elif mpu.find("homeshop18")!=-1:
-
 
1705
            mpu = "http://m.homeshop18.com/product.mobi?productId="+item['identifier']
-
 
1706
        elif mpu.find("saholic.com")!=1:
-
 
1707
            mpu = "http://m.saholic.com"+mpu[mpu.find("/"):]
-
 
1708
        elif mpu.find("shopclues.com")!=1:
-
 
1709
            mpu = "http://m."+mpu[mpu.find("shopclues.com"):]
-
 
1710
        else:
-
 
1711
            pass
-
 
1712
    
1700
    return {'marketPlaceUrl':item.get('marketPlaceUrl'),'available_price':int(item.get('available_price')),'source_product_name':item.get('source_product_name'),'thumbnail':item.get('thumbnail'),'source_id':int(item.get('source_id'))}
1713
    return {'marketPlaceUrl':mpu,'available_price':int(item.get('available_price')),'source_product_name':item.get('source_product_name'),'thumbnail':item.get('thumbnail'),'source_id':int(item.get('source_id'))}
1701
 
1714
 
1702
def getItemByMerchantIdentifier(identifier, source_id):
1715
def getItemByMerchantIdentifier(identifier, source_id):
1703
    skuData = None
1716
    skuData = None
1704
    if source_id in (1,2,4,5,6,7):
1717
    if source_id in (1,2,4,5,6,7):
1705
        skuData = get_mongo_connection().Catalog.MasterData.find_one({'identifier':identifier.strip(), 'source_id':source_id})
1718
        skuData = get_mongo_connection().Catalog.MasterData.find_one({'identifier':identifier.strip(), 'source_id':source_id})
Line 2130... Line 2143...
2130
    outer_query.append({'totalPoints':query})
2143
    outer_query.append({'totalPoints':query})
2131
    all_deals = list(get_mongo_connection().Catalog.Deals.find({"$and":outer_query},{'_id':1}).sort([('totalPoints',pymongo.DESCENDING),('bestSellerPoints',pymongo.DESCENDING),('nlcPoints',pymongo.DESCENDING),('rank',pymongo.DESCENDING)]).skip(offset).limit(limit))
2144
    all_deals = list(get_mongo_connection().Catalog.Deals.find({"$and":outer_query},{'_id':1}).sort([('totalPoints',pymongo.DESCENDING),('bestSellerPoints',pymongo.DESCENDING),('nlcPoints',pymongo.DESCENDING),('rank',pymongo.DESCENDING)]).skip(offset).limit(limit))
2132
    returnObj = []
2145
    returnObj = []
2133
    for deal in all_deals:
2146
    for deal in all_deals:
2134
        item = list(get_mongo_connection().Catalog.MasterData.find({'_id':deal['_id']}))
2147
        item = list(get_mongo_connection().Catalog.MasterData.find({'_id':deal['_id']}))
2135
        returnObj.append(getItemObjForStaticDeals(item[0]))
2148
        returnObj.append(getItemObjForStaticDeals(item[0]),transform=True)
2136
    return returnObj
2149
    return returnObj
2137
 
2150
 
2138
def searchDummyDeals(search_term , limit, offset):
2151
def searchDummyDeals(search_term , limit, offset):
2139
    data = []
2152
    data = []
2140
    uniqueMap = {}
2153
    uniqueMap = {}
Line 2183... Line 2196...
2183
    for d in collection:
2196
    for d in collection:
2184
        if d['available_price'] < cheapest:
2197
        if d['available_price'] < cheapest:
2185
            cheapestDetails = d
2198
            cheapestDetails = d
2186
            cheapest = int(d['available_price'])
2199
            cheapest = int(d['available_price'])
2187
        if returnMap.has_key(d['source_id']):
2200
        if returnMap.has_key(d['source_id']):
2188
            d = getItemObjForStaticDeals(d)
2201
            d = getItemObjForStaticDeals(d,transform=True)
2189
            d['toShowStore'] = 0
2202
            d['toShowStore'] = 0
2190
            returnMap[d['source_id']].append(d)
2203
            returnMap[d['source_id']].append(d)
2191
        else:
2204
        else:
2192
            temp = []
2205
            temp = []
2193
            d = getItemObjForStaticDeals(d)
2206
            d = getItemObjForStaticDeals(d,transform=True)
2194
            d['toShowStore'] = 1
2207
            d['toShowStore'] = 1
2195
            temp.append(d)
2208
            temp.append(d)
2196
            returnMap[d['source_id']] = temp
2209
            returnMap[d['source_id']] = temp
2197
    returnMap['cheapest'] = cheapestDetails
2210
    returnMap['cheapest'] = cheapestDetails
2198
    for y in returnMap.itervalues():
2211
    for y in returnMap.itervalues():