Compare commits
2 commits
736a1a07e7
...
a90496bd0b
Author | SHA1 | Date | |
---|---|---|---|
a90496bd0b | |||
5b6344a695 |
1 changed files with 6 additions and 3 deletions
|
@ -183,13 +183,16 @@ async def advanced_search(
|
||||||
]
|
]
|
||||||
if sort_by == "price":
|
if sort_by == "price":
|
||||||
orderings = [
|
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,
|
*orderings,
|
||||||
]
|
]
|
||||||
params["last_update_key"] = "last_update"
|
params["last_update_key"] = "last_update"
|
||||||
query = " ".join(
|
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),
|
" ".join(joins),
|
||||||
"WHERE" if constraints else "",
|
"WHERE" if constraints else "",
|
||||||
" AND ".join(constraints),
|
" AND ".join(constraints),
|
||||||
|
@ -198,7 +201,7 @@ async def advanced_search(
|
||||||
f"LIMIT {limit} OFFSET {offset}",
|
f"LIMIT {limit} OFFSET {offset}",
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
logger.critical("Query: %s", (query, params))
|
logger.debug("Query: %s", (query, params))
|
||||||
await db.execute(query, params)
|
await db.execute(query, params)
|
||||||
rows = await db.fetchall()
|
rows = await db.fetchall()
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue