| Line 485... |
Line 485... |
| 485 |
if category != -1:
|
485 |
if category != -1:
|
| 486 |
query = query.filter_by(category=category)
|
486 |
query = query.filter_by(category=category)
|
| 487 |
return query
|
487 |
return query
|
| 488 |
|
488 |
|
| 489 |
def get_best_deals():
|
489 |
def get_best_deals():
|
| 490 |
items = Item.query.filter(Item.bestDealValue != None).order_by(desc(Item.bestDealValue)).all()
|
490 |
items = Item.query.filter(Item.bestDealValue != None).group_by(Item.catalog_item_id).order_by(desc(Item.bestDealValue)).all()
|
| 491 |
return get_thrift_item_list(items)
|
491 |
return get_thrift_item_list(items)
|
| 492 |
|
492 |
|
| 493 |
def get_best_deals_count():
|
493 |
def get_best_deals_count():
|
| 494 |
count = Item.query.filter(Item.bestDealValue != None).count()
|
494 |
count = Item.query.filter(Item.bestDealValue != None).group_by(Item.catalog_item_id).count()
|
| 495 |
return count
|
495 |
return count
|
| 496 |
|
496 |
|
| 497 |
def get_best_deals_catalog_ids(start_index, stop_index, category=-1):
|
497 |
def get_best_deals_catalog_ids(start_index, stop_index, category=-1):
|
| 498 |
query = Item.query.filter(Item.bestDealValue != None)
|
498 |
query = Item.query.filter(Item.bestDealValue != None)
|
| 499 |
if category != -1:
|
499 |
if category != -1:
|
| 500 |
query = query.filter_by(category=category)
|
500 |
query = query.filter_by(category=category)
|
| 501 |
best_deal_items = query.order_by(desc(Item.bestDealValue)).all()[start_index:stop_index]
|
501 |
best_deal_items = query.group_by(Item.catalog_item_id).order_by(desc(Item.bestDealValue)).all()[start_index:stop_index]
|
| 502 |
return [item.catalog_item_id for item in best_deal_items]
|
502 |
return [item.catalog_item_id for item in best_deal_items]
|
| 503 |
|
503 |
|
| 504 |
def get_latest_arrivals(limit):
|
504 |
def get_latest_arrivals(limit):
|
| 505 |
items = Item.query.order_by(desc(Item.startDate)).all()[0:limit]
|
505 |
items = Item.query.group_by(Item.catalog_item_id).order_by(desc(Item.startDate)).all()[0:limit]
|
| 506 |
return get_thrift_item_list(items)
|
506 |
return get_thrift_item_list(items)
|
| 507 |
|
507 |
|
| 508 |
def get_latest_arrivals_count(limit):
|
508 |
def get_latest_arrivals_count(limit):
|
| 509 |
#FIXME: This method has not been functionally tested. Have to talk to Rajveer to check where is it used.
|
509 |
#FIXME: This method has not been functionally tested. Have to talk to Rajveer to check where is it used.
|
| 510 |
count = min(Item.query.count(), limit)
|
510 |
count = min(Item.query.count(), limit)
|
| Line 512... |
Line 512... |
| 512 |
|
512 |
|
| 513 |
def get_latest_arrivals_catalog_ids(start_index, stop_index, category=-1):
|
513 |
def get_latest_arrivals_catalog_ids(start_index, stop_index, category=-1):
|
| 514 |
query = Item.query
|
514 |
query = Item.query
|
| 515 |
if category != -1:
|
515 |
if category != -1:
|
| 516 |
query = query.filter_by(category=category)
|
516 |
query = query.filter_by(category=category)
|
| 517 |
latest_arrivals = query.order_by(desc(Item.startDate)).all()[start_index:stop_index]
|
517 |
latest_arrivals = query.group_by(Item.catalog_item_id).order_by(desc(Item.startDate)).all()[start_index:stop_index]
|
| 518 |
return [item.catalog_item_id for item in latest_arrivals]
|
518 |
return [item.catalog_item_id for item in latest_arrivals]
|
| 519 |
|
519 |
|
| 520 |
def get_thrift_item_list(items):
|
520 |
def get_thrift_item_list(items):
|
| 521 |
ret_items = []
|
521 |
ret_items = []
|
| 522 |
for item in items:
|
522 |
for item in items:
|
| 523 |
if item:
|
523 |
if item:
|