Subversion Repositories SmartDukaan

Rev

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

Rev 14263 Rev 14306
Line 29... Line 29...
29
now = datetime.now()
29
now = datetime.now()
30
 
30
 
31
class __SkuInfo:
31
class __SkuInfo:
32
    
32
    
33
    def __init__(self, _id, skuBundleId, category_id, mrp, available_price, source_id, rank, maxNlc, minNlc, schemeAmount, minDiscount, \
33
    def __init__(self, _id, skuBundleId, category_id, mrp, available_price, source_id, rank, maxNlc, minNlc, schemeAmount, minDiscount, \
34
                 maxDiscount, discountType, dp, nlcPoints, bestSellerPoints, totalPoints, status, in_stock, maxprice, brand):
34
                 maxDiscount, discountType, dp, nlcPoints, bestSellerPoints, totalPoints, status, in_stock, maxprice, brand, dealType, dealPoints):
35
        self._id = _id
35
        self._id = _id
36
        self.skuBundleId = skuBundleId
36
        self.skuBundleId = skuBundleId
37
        self.category_id = category_id
37
        self.category_id = category_id
38
        self.mrp = mrp
38
        self.mrp = mrp
39
        self.available_price = available_price
39
        self.available_price = available_price
Line 51... Line 51...
51
        self.totalPoints = totalPoints
51
        self.totalPoints = totalPoints
52
        self.status = status
52
        self.status = status
53
        self.in_stock = in_stock
53
        self.in_stock = in_stock
54
        self.maxprice = maxprice
54
        self.maxprice = maxprice
55
        self.brand = brand
55
        self.brand = brand
-
 
56
        self.dealType = dealType
-
 
57
        self.dealPoints = dealPoints 
56
 
58
 
57
 
59
 
58
def get_mongo_connection(host=options.mongoHost, port=27017):
60
def get_mongo_connection(host=options.mongoHost, port=27017):
59
    global con
61
    global con
60
    if con is None:
62
    if con is None:
Line 80... Line 82...
80
        #topSkus = collection.find( {'_id':664})
82
        #topSkus = collection.find( {'_id':664})
81
        for sku in topSkus:
83
        for sku in topSkus:
82
            """Fix this """
84
            """Fix this """
83
            #TODO Compute deal flags else where.
85
            #TODO Compute deal flags else where.
84
            info = __SkuInfo(sku['_id'], sku['skuBundleId'], sku['category_id'], sku['mrp'], sku['available_price'], sku['source_id'], sku['rank'], None, None, 0.0, None, \
86
            info = __SkuInfo(sku['_id'], sku['skuBundleId'], sku['category_id'], sku['mrp'], sku['available_price'], sku['source_id'], sku['rank'], None, None, 0.0, None, \
85
                             None, None, None, None, None, None, sku['status'], sku['in_stock'],None,sku['brand'].strip().upper())
87
                             None, None, None, None, None, None, sku['status'], sku['in_stock'],None,sku['brand'].strip().upper(), 0, 0)
86
            exceptionalNlc = list(get_mongo_connection().Catalog.ExceptionalNlc.find( {"$and" : [ {'sku':info._id}, {'overrideNlc':1} ]} ))
88
            exceptionalNlc = list(get_mongo_connection().Catalog.ExceptionalNlc.find( {"$and" : [ {'sku':info._id}, {'overrideNlc':1} ]} ))
87
            if len(exceptionalNlc) > 0:
89
            if len(exceptionalNlc) > 0:
88
                """Exceptional nlc found, no need to calculate max and min R-nlc"""
90
                """Exceptional nlc found, no need to calculate max and min R-nlc"""
89
                info.maxNlc = exceptionalNlc[0]['maxNlc']
91
                info.maxNlc = exceptionalNlc[0]['maxNlc']
90
                info.minNlc = exceptionalNlc[0]['minNlc']
92
                info.minNlc = exceptionalNlc[0]['minNlc']
Line 174... Line 176...
174
                    except:
176
                    except:
175
                        pass
177
                        pass
176
        populated = populated + 300
178
        populated = populated + 300
177
        time.sleep(10) 
179
        time.sleep(10) 
178
 
180
 
-
 
181
def addManualDealsInfo():
-
 
182
    global LATEST_UPDATED_ITEMS
-
 
183
    for sku in LATEST_UPDATED_ITEMS:
-
 
184
        manualDeal = list(get_mongo_connection().Catalog.ManualDeals.find({'startDate':{'$lte':to_java_date(datetime.now())},'endDate':{'$gte':to_java_date(datetime.now())},'source_id':sku.source_id, 'sku':sku._id}))
-
 
185
        if len(manualDeal) > 0:
-
 
186
            sku.dealType = manualDeal[0]['dealType']
-
 
187
 
179
def calculateNlcPoints():
188
def calculateNlcPoints():
180
    global LATEST_UPDATED_ITEMS
189
    global LATEST_UPDATED_ITEMS
181
    for sku in LATEST_UPDATED_ITEMS:
190
    for sku in LATEST_UPDATED_ITEMS:
182
        if sku.maxNlc and sku.minNlc:
191
        if sku.maxNlc and sku.minNlc:
183
            
192
            
Line 273... Line 282...
273
 
282
 
274
def main():
283
def main():
275
    try:
284
    try:
276
        populateStuff()
285
        populateStuff()
277
        calculateNlc()
286
        calculateNlc()
-
 
287
        addManualDealsInfo()
278
    finally:
288
    finally:
279
        session.close()
289
        session.close()
280
    calculateNlcPoints()
290
    calculateNlcPoints()
281
    commitData()
291
    commitData()
282
    addBestSellerPoints()
292
    addBestSellerPoints()