Subversion Repositories SmartDukaan

Rev

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

Rev 7782 Rev 7897
Line 1276... Line 1276...
1276
        query = query.filter(ProductNotification.addedOn > start_datetime)
1276
        query = query.filter(ProductNotification.addedOn > start_datetime)
1277
   
1277
   
1278
    notifications = query.order_by(desc('addedOn')).all()
1278
    notifications = query.order_by(desc('addedOn')).all()
1279
    return notifications
1279
    return notifications
1280
 
1280
 
1281
def get_product_notification_request_count(start_datetime):
1281
def get_product_notification_request_count(start_datetime, categoryId):
1282
    '''
1282
    '''
1283
    Returns list of items and the counts of product notification requests
1283
    Returns list of items and the counts of product notification requests
1284
    '''
1284
    '''
-
 
1285
    if categoryId:
-
 
1286
        categories = get_child_categories(categoryId)
-
 
1287
        items = Item.query.filter(Item.category.in_(categories)).all()
-
 
1288
        item_ids = [item.id for item in items]
-
 
1289
    
1285
    print start_datetime
1290
    print start_datetime
1286
    query = session.query(ProductNotification, func.count(ProductNotification.email).label('count'))
1291
    query = session.query(ProductNotification, func.count(ProductNotification.email).label('count'))
1287
   
1292
   
1288
    if start_datetime:
1293
    if start_datetime:
1289
        query = query.filter(ProductNotification.addedOn > start_datetime)
1294
        query = query.filter(ProductNotification.addedOn > start_datetime)
1290
   
1295
    if categoryId:
-
 
1296
        query = query.filter(ProductNotification.item_id.in_(item_ids))
1291
    counts = query.group_by(ProductNotification.item_id).order_by(desc('count')).all()
1297
    counts = query.group_by(ProductNotification.item_id).order_by(desc('count')).all()
1292
    return counts
1298
    return counts
1293
 
1299
 
1294
def close_session():
1300
def close_session():
1295
    if session.is_active:
1301
    if session.is_active:
Line 1798... Line 1804...
1798
            amazonItem.mfnPriceLastUpdatedOnSc = to_py_date(timestamp)
1804
            amazonItem.mfnPriceLastUpdatedOnSc = to_py_date(timestamp)
1799
            session.commit()
1805
            session.commit()
1800
    else:
1806
    else:
1801
        return False
1807
        return False
1802
    
1808
    
1803
    
-
 
1804
    
-
 
1805
    
-
 
1806
    
-
 
1807
    
1809
def get_all_parent_categories():
-
 
1810
    return Category.query.filter_by(parent_category_id=10000).all()
1808
    
1811
    
1809
1812