Subversion Repositories SmartDukaan

Rev

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

Rev 14331 Rev 14388
Line 56... Line 56...
56
        self.status = status
56
        self.status = status
57
        self.in_stock = in_stock
57
        self.in_stock = in_stock
58
        self.maxprice = maxprice
58
        self.maxprice = maxprice
59
        self.brand = brand
59
        self.brand = brand
60
        self.dealType = dealType
60
        self.dealType = dealType
61
        self.dealPoints = dealPoints 
61
        self.dealPoints = dealPoints
62
 
62
 
63
 
63
 
64
def get_mongo_connection(host=options.mongoHost, port=27017):
64
def get_mongo_connection(host=options.mongoHost, port=27017):
65
    global con
65
    global con
66
    if con is None:
66
    if con is None:
Line 254... Line 254...
254
        else:
254
        else:
255
            sku['bestSellerPoints'] = -100
255
            sku['bestSellerPoints'] = -100
256
        #sku['totalPoints'] = sku['bestSellerPoints'] + sku['nlcPoints']
256
        #sku['totalPoints'] = sku['bestSellerPoints'] + sku['nlcPoints']
257
        get_mongo_connection().Catalog.Deals.update({'_id':sku['_id']},{'$set':{'bestSellerPoints':sku['bestSellerPoints']}},multi=False)
257
        get_mongo_connection().Catalog.Deals.update({'_id':sku['_id']},{'$set':{'bestSellerPoints':sku['bestSellerPoints']}},multi=False)
258
    
258
    
-
 
259
    shortageSkus = list(get_mongo_connection().Catalog.Deals.find({"$and":[{'is_shortage': 1 }, { 'source_id' : { "$in": SOURCE_MAP.values() } }] }).distinct('_id'))
-
 
260
 
259
    for sku in allItems:
261
    for sku in allItems:
260
        deal_item = list(get_mongo_connection().Catalog.Deals.find({'skuBundleId':sku['skuBundleId']}).sort('bestSellerPoints',pymongo.DESCENDING).limit(1))
262
        deal_item = list(get_mongo_connection().Catalog.Deals.find({'skuBundleId':sku['skuBundleId']}).sort('bestSellerPoints',pymongo.DESCENDING).limit(1))
261
        sku['catalogBestSellerPoints'] = deal_item[0]['bestSellerPoints']
263
        sku['catalogBestSellerPoints'] = deal_item[0]['bestSellerPoints']
-
 
264
        shortagePoints = 50 if sku['_id'] in shortageSkus else 0
262
        sku['totalPoints'] = sku['catalogBestSellerPoints'] + sku['nlcPoints']
265
        sku['totalPoints'] = sku['catalogBestSellerPoints'] + sku['nlcPoints'] + shortagePoints 
263
        get_mongo_connection().Catalog.Deals.update({'_id':sku['_id']},{'$set':{'catalogBestSellerPoints':sku['catalogBestSellerPoints'],'totalPoints':sku['totalPoints']}},multi=False)
266
        get_mongo_connection().Catalog.Deals.update({'_id':sku['_id']},{'$set':{'catalogBestSellerPoints':sku['catalogBestSellerPoints'],'totalPoints':sku['totalPoints']}},multi=False)
264
 
267
 
265
 
268
 
266
def populateNegativeDeals():
269
def populateNegativeDeals():
267
    negativeDeals = get_mongo_connection().Catalog.NegativeDeals.find().distinct('sku')
270
    negativeDeals = get_mongo_connection().Catalog.NegativeDeals.find().distinct('sku')