| Line 379... |
Line 379... |
| 379 |
raise InventoryServiceException(101, "bad item")
|
379 |
raise InventoryServiceException(101, "bad item")
|
| 380 |
|
380 |
|
| 381 |
warehouses = item.currentInventory.warehouse
|
381 |
warehouses = item.currentInventory.warehouse
|
| 382 |
return warehouses
|
382 |
return warehouses
|
| 383 |
|
383 |
|
| 384 |
def get_best_sellers(start_index, stop_index, category=None):
|
384 |
def get_best_sellers(start_index, stop_index, category=-1):
|
| 385 |
query = get_best_sellers_query(category)
|
385 |
query = get_best_sellers_query(category)
|
| 386 |
best_sellers = query.order_by(asc(Item.bestSellingRank)).all()[start_index:stop_index]
|
386 |
best_sellers = query.order_by(asc(Item.bestSellingRank)).all()[start_index:stop_index]
|
| 387 |
return get_thrift_item_list(best_sellers)
|
387 |
return get_thrift_item_list(best_sellers)
|
| 388 |
|
388 |
|
| 389 |
def get_best_sellers_count(category):
|
389 |
def get_best_sellers_count(category):
|
| 390 |
query = get_best_sellers_query(category)
|
390 |
query = get_best_sellers_query(category)
|
| 391 |
return query.count()
|
391 |
return query.count()
|
| 392 |
|
392 |
|
| 393 |
def get_best_sellers_catalog_ids(start_index, stop_index, category):
|
393 |
def get_best_sellers_catalog_ids(start_index, stop_index, category=-1):
|
| 394 |
query = get_best_sellers_query(category)
|
394 |
query = get_best_sellers_query(category)
|
| 395 |
best_sellers = query.order_by(asc(Item.bestSellingRank)).all()[start_index:stop_index]
|
395 |
best_sellers = query.order_by(asc(Item.bestSellingRank)).all()[start_index:stop_index]
|
| 396 |
return [item.catalog_item_id for item in best_sellers]
|
396 |
return [item.catalog_item_id for item in best_sellers]
|
| 397 |
|
397 |
|
| 398 |
def get_best_sellers_query(category):
|
398 |
def get_best_sellers_query(category):
|
| 399 |
query = Item.query.filter(Item.bestSellingRank != None)
|
399 |
query = Item.query.filter(Item.bestSellingRank != None)
|
| 400 |
if category != None:
|
400 |
if category != -1:
|
| 401 |
query = query.filter_by(category=category)
|
401 |
query = query.filter_by(category=category)
|
| 402 |
return query
|
402 |
return query
|
| 403 |
|
403 |
|
| 404 |
def get_best_deals():
|
404 |
def get_best_deals():
|
| 405 |
items = Item.query.filter(Item.bestDealValue != None).order_by(desc(Item.bestDealValue)).all()
|
405 |
items = Item.query.filter(Item.bestDealValue != None).order_by(desc(Item.bestDealValue)).all()
|
| 406 |
return get_thrift_item_list(items)
|
406 |
return get_thrift_item_list(items)
|
| 407 |
|
407 |
|
| 408 |
def get_best_deals_count():
|
408 |
def get_best_deals_count():
|
| 409 |
return Item.query.filter(Item.bestDealValue != None).count()
|
409 |
return Item.query.filter(Item.bestDealValue != None).count()
|
| 410 |
|
410 |
|
| 411 |
def get_best_deals_catalog_ids(start_index, stop_index, category=None):
|
411 |
def get_best_deals_catalog_ids(start_index, stop_index, category=-1):
|
| 412 |
query = Item.query.filter(Item.bestDealValue != None)
|
412 |
query = Item.query.filter(Item.bestDealValue != None)
|
| 413 |
if category != None:
|
413 |
if category != -1:
|
| 414 |
query = query.filter_by(category=category)
|
414 |
query = query.filter_by(category=category)
|
| 415 |
best_deal_items = query.order_by(desc(Item.bestDealValue)).all()[start_index:stop_index]
|
415 |
best_deal_items = query.order_by(desc(Item.bestDealValue)).all()[start_index:stop_index]
|
| 416 |
return [item.catalog_item_id for item in best_deal_items]
|
416 |
return [item.catalog_item_id for item in best_deal_items]
|
| 417 |
|
417 |
|
| 418 |
def get_latest_arrivals(limit):
|
418 |
def get_latest_arrivals(limit):
|
| Line 421... |
Line 421... |
| 421 |
|
421 |
|
| 422 |
def get_latest_arrivals_count(limit):
|
422 |
def get_latest_arrivals_count(limit):
|
| 423 |
#FIXME: This method has not been functionally tested. Have to talk to Rajveer to check where is it used.
|
423 |
#FIXME: This method has not been functionally tested. Have to talk to Rajveer to check where is it used.
|
| 424 |
return min(Item.query.count(), limit)
|
424 |
return min(Item.query.count(), limit)
|
| 425 |
|
425 |
|
| 426 |
def get_latest_arrivals_catalog_ids(start_index, stop_index, category=None):
|
426 |
def get_latest_arrivals_catalog_ids(start_index, stop_index, category=-1):
|
| 427 |
query = Item.query
|
427 |
query = Item.query
|
| 428 |
if category != None:
|
428 |
if category != -1:
|
| 429 |
query = query.filter_by(category=category)
|
429 |
query = query.filter_by(category=category)
|
| 430 |
latest_arrivals = query.order_by(desc(Item.startDate)).all()[start_index:stop_index]
|
430 |
latest_arrivals = query.order_by(desc(Item.startDate)).all()[start_index:stop_index]
|
| 431 |
return [item.catalog_item_id for item in latest_arrivals]
|
431 |
return [item.catalog_item_id for item in latest_arrivals]
|
| 432 |
|
432 |
|
| 433 |
def get_thrift_item_list(items):
|
433 |
def get_thrift_item_list(items):
|