Use foil price if the card in collection is foil
This commit is contained in:
parent
5b6344a695
commit
a90496bd0b
1 changed files with 5 additions and 2 deletions
|
@ -183,13 +183,16 @@ async def advanced_search(
|
|||
]
|
||||
if sort_by == "price":
|
||||
orderings = [
|
||||
"CAST(COALESCE(card_prices.usd, card_prices.usd_foil, 0) as decimal) DESC",
|
||||
"CAST(COALESCE(CASE WHEN \"copies\".\"isFoil\" THEN card_prices.usd_foil ELSE card_prices.usd END, 0) as decimal) DESC",
|
||||
*orderings,
|
||||
]
|
||||
params["last_update_key"] = "last_update"
|
||||
query = " ".join(
|
||||
[
|
||||
"SELECT cards.*, card_prices.* FROM cards",
|
||||
"SELECT cards.*, card_prices.*",
|
||||
", CASE WHEN \"copies\".\"isFoil\" THEN card_prices.usd_foil",
|
||||
" ELSE card_prices.usd END AS usd",
|
||||
"FROM cards",
|
||||
" ".join(joins),
|
||||
"WHERE" if constraints else "",
|
||||
" AND ".join(constraints),
|
||||
|
|
Loading…
Reference in a new issue