Add sort by created date
This commit is contained in:
parent
1358f38419
commit
2554900554
2 changed files with 19 additions and 1 deletions
|
@ -194,6 +194,11 @@ async def advanced_search(
|
|||
'CAST(COALESCE(CASE WHEN "copies"."isFoil" THEN cards.price_usd_foil ELSE cards.price_usd END, 0) as decimal) DESC',
|
||||
*orderings,
|
||||
]
|
||||
elif sort_by == "created":
|
||||
orderings = [
|
||||
"copies.created_date DESC",
|
||||
*orderings,
|
||||
]
|
||||
params["last_update_key"] = "last_update"
|
||||
query = " ".join(
|
||||
[
|
||||
|
|
|
@ -48,6 +48,7 @@ decodeStatistics =
|
|||
type SortBy
|
||||
= PriceDescending
|
||||
| RarityDescending
|
||||
| CreatedDescending
|
||||
|
||||
|
||||
type alias Criteria =
|
||||
|
@ -124,6 +125,9 @@ searchQuery criteria =
|
|||
|
||||
RarityDescending ->
|
||||
"rarity"
|
||||
|
||||
CreatedDescending ->
|
||||
"created"
|
||||
in
|
||||
[ Url.Builder.string "q" criteria.query
|
||||
, Url.Builder.string "sort_by" (toString criteria.sortBy)
|
||||
|
@ -173,6 +177,7 @@ parseUrl =
|
|||
(Dict.fromList
|
||||
[ ( "rarity", RarityDescending )
|
||||
, ( "price", PriceDescending )
|
||||
, ( "created", CreatedDescending )
|
||||
]
|
||||
)
|
||||
|> Url.Parser.Query.map (Maybe.withDefault PriceDescending)
|
||||
|
@ -386,6 +391,9 @@ sortDropdown =
|
|||
RarityDescending ->
|
||||
"Rarity DESC"
|
||||
|
||||
CreatedDescending ->
|
||||
"Created DESC"
|
||||
|
||||
selectAttrs =
|
||||
[ Background.color UI.colors.secondary
|
||||
, Border.width 1
|
||||
|
@ -421,7 +429,12 @@ sortDropdown =
|
|||
toString sortBy
|
||||
in
|
||||
Dropdown.basic
|
||||
{ itemsFromModel = always [ PriceDescending, RarityDescending ]
|
||||
{ itemsFromModel =
|
||||
always
|
||||
[ PriceDescending
|
||||
, RarityDescending
|
||||
, CreatedDescending
|
||||
]
|
||||
, selectionFromModel = .criteria >> .sortBy >> Just
|
||||
, dropdownMsg = DropdownMsg
|
||||
, onSelectMsg = SortSelected
|
||||
|
|
Loading…
Reference in a new issue