@@ -75,6 +75,9 @@ export function createListingRepository(db) {
|
||||
text = "",
|
||||
category,
|
||||
conditionId,
|
||||
setName,
|
||||
eventName,
|
||||
tag,
|
||||
minPriceMinor,
|
||||
maxPriceMinor,
|
||||
page = 1,
|
||||
@@ -104,6 +107,18 @@ export function createListingRepository(db) {
|
||||
conditions.push(eq(inventoryItems.conditionId, conditionId));
|
||||
}
|
||||
|
||||
if (typeof setName === "string" && setName.trim().length > 0) {
|
||||
conditions.push(ilike(products.setName, setName));
|
||||
}
|
||||
|
||||
if (typeof eventName === "string" && eventName.trim().length > 0) {
|
||||
conditions.push(ilike(products.eventName, eventName));
|
||||
}
|
||||
|
||||
if (typeof tag === "string" && tag.trim().length > 0) {
|
||||
conditions.push(sql`${products.tags}::text ILIKE ${`%${tag}%`}`);
|
||||
}
|
||||
|
||||
if (typeof minPriceMinor === "number") {
|
||||
conditions.push(sql`listings.asking_price_minor >= ${minPriceMinor}`);
|
||||
}
|
||||
|
||||
@@ -19,6 +19,9 @@ export function createSearchQuery({
|
||||
query = "",
|
||||
category,
|
||||
conditionId,
|
||||
setName,
|
||||
eventName,
|
||||
tag,
|
||||
minPriceMinor,
|
||||
maxPriceMinor,
|
||||
page = 1,
|
||||
@@ -70,6 +73,15 @@ export function createSearchQuery({
|
||||
...(typeof conditionId === "string" && conditionId.trim().length > 0
|
||||
? { conditionId: conditionId.trim() }
|
||||
: {}),
|
||||
...(typeof setName === "string" && setName.trim().length > 0
|
||||
? { setName: setName.trim() }
|
||||
: {}),
|
||||
...(typeof eventName === "string" && eventName.trim().length > 0
|
||||
? { eventName: eventName.trim() }
|
||||
: {}),
|
||||
...(typeof tag === "string" && tag.trim().length > 0
|
||||
? { tag: tag.trim().toLowerCase() }
|
||||
: {}),
|
||||
...(typeof minPriceMinor === "number" ? { minPriceMinor } : {}),
|
||||
...(typeof maxPriceMinor === "number" ? { maxPriceMinor } : {}),
|
||||
page,
|
||||
|
||||
@@ -32,6 +32,9 @@ export async function registerPublicSearchRoutes(app, options) {
|
||||
query: request.query.query,
|
||||
category: request.query.category,
|
||||
conditionId: request.query.conditionId,
|
||||
setName: request.query.setName,
|
||||
eventName: request.query.eventName,
|
||||
tag: request.query.tag,
|
||||
minPriceMinor: coerceNumber(
|
||||
request.query.minPriceMinor,
|
||||
"minPriceMinor",
|
||||
|
||||
Reference in New Issue
Block a user