This commit is contained in:
@@ -161,6 +161,16 @@ export function createListingRepository(db) {
|
||||
}
|
||||
|
||||
const offset = (page - 1) * limit;
|
||||
const marketValue = sql`COALESCE(
|
||||
(SELECT ${marketValueOverrides.valueMinor}
|
||||
FROM ${marketValueOverrides}
|
||||
WHERE ${marketValueOverrides.inventoryItemId} = ${inventoryItems.id}
|
||||
ORDER BY ${marketValueOverrides.createdAt} DESC LIMIT 1),
|
||||
(SELECT ${marketValuations.valueMinor}
|
||||
FROM ${marketValuations}
|
||||
WHERE ${marketValuations.inventoryItemId} = ${inventoryItems.id}
|
||||
ORDER BY ${marketValuations.calculatedAt} DESC LIMIT 1)
|
||||
)`;
|
||||
const sortOrder =
|
||||
sort === "updated"
|
||||
? desc(listings.updatedAt)
|
||||
@@ -168,6 +178,10 @@ export function createListingRepository(db) {
|
||||
? products.name
|
||||
: sort === "name_desc"
|
||||
? desc(products.name)
|
||||
: sort === "market_low"
|
||||
? sql`${marketValue} ASC NULLS LAST`
|
||||
: sort === "market_high"
|
||||
? sql`${marketValue} DESC NULLS LAST`
|
||||
: sort === "price_low"
|
||||
? listings.askingPriceMinor
|
||||
: sort === "price_high"
|
||||
|
||||
@@ -67,8 +67,8 @@ export function createSearchQuery({
|
||||
throw new Error("minPriceMinor must be <= maxPriceMinor");
|
||||
}
|
||||
|
||||
if (!["recent", "updated", "name_asc", "name_desc", "price_low", "price_high"].includes(sort)) {
|
||||
throw new Error("sort must be recent, updated, name_asc, name_desc, price_low, or price_high");
|
||||
if (!["recent", "updated", "name_asc", "name_desc", "price_low", "price_high", "market_low", "market_high"].includes(sort)) {
|
||||
throw new Error("sort must be recent, updated, name_asc, name_desc, price_low, price_high, market_low, or market_high");
|
||||
}
|
||||
|
||||
return {
|
||||
|
||||
@@ -66,6 +66,8 @@ test("accepts only the supported public search sort values", () => {
|
||||
assert.equal(createSearchQuery({ sort: "updated" }).sort, "updated");
|
||||
assert.equal(createSearchQuery({ sort: "name_asc" }).sort, "name_asc");
|
||||
assert.equal(createSearchQuery({ sort: "name_desc" }).sort, "name_desc");
|
||||
assert.equal(createSearchQuery({ sort: "market_low" }).sort, "market_low");
|
||||
assert.equal(createSearchQuery({ sort: "market_high" }).sort, "market_high");
|
||||
assert.throws(
|
||||
() => createSearchQuery({ sort: "random" }),
|
||||
/sort must be recent/,
|
||||
|
||||
@@ -4,3 +4,4 @@ export default { title: 'Atoms/CatalogSortSelect', component: CatalogSortSelect
|
||||
|
||||
export const RecentlyAdded = { args: { modelValue: 'recent' } };
|
||||
export const NameAscending = { args: { modelValue: 'name_asc' } };
|
||||
export const MarketValueDescending = { args: { modelValue: 'market_high' } };
|
||||
|
||||
@@ -19,6 +19,8 @@ defineEmits(['update:modelValue']);
|
||||
<option value="name_desc">Name Z-A</option>
|
||||
<option value="price_low">Price: low to high</option>
|
||||
<option value="price_high">Price: high to low</option>
|
||||
<option value="market_low">Market value: low to high</option>
|
||||
<option value="market_high">Market value: high to low</option>
|
||||
</select>
|
||||
</label>
|
||||
</template>
|
||||
|
||||
@@ -166,6 +166,7 @@ Remaining roadmap areas are approved external provider credentials/adapters, bro
|
||||
- Public catalog sorting now supports recently added, recently updated, name A-Z, name Z-A, price low-to-high, and price high-to-low through a URL-synchronized atomic sort control. Broader inventory filter parity and market-value sorting remain.
|
||||
- Public catalog filtering now supports URL-synchronized set, event, and tag text filters through a reusable atomic text-filter control and the shared search API.
|
||||
- Public catalog filtering now supports explicit Available, Pending, Sold, and All status modes plus a 30-day Newly added toggle through the shared search API and atomic controls.
|
||||
- Public catalog sorting now supports latest manual/calculated market value low-to-high and high-to-low, with null values placed last.
|
||||
|
||||
## Local Commands
|
||||
|
||||
|
||||
Reference in New Issue
Block a user