Compare commits

...

2 commits

Author SHA1 Message Date
a90496bd0b Use foil price if the card in collection is foil 2022-07-28 20:04:04 -04:00
5b6344a695 Fix price ordering
NULL price values were being sorted before cards with prices available.
2022-07-28 19:30:50 -04:00

View file

@ -183,13 +183,16 @@ async def advanced_search(
]
if sort_by == "price":
orderings = [
"CAST(COALESCE(card_prices.usd, card_prices.usd_foil) 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),
@ -198,7 +201,7 @@ async def advanced_search(
f"LIMIT {limit} OFFSET {offset}",
]
)
logger.critical("Query: %s", (query, params))
logger.debug("Query: %s", (query, params))
await db.execute(query, params)
rows = await db.fetchall()