Fix beers with ibu null not being shown

This commit is contained in:
2024-06-23 17:53:00 +02:00
parent 8b3676b275
commit 2a58e8f2ea
+9 -3
View File
@@ -47,7 +47,7 @@ export async function findDrinksFromSearch(searchParams: URLSearchParams) : Prom
// Beers
if(searchParams.has("drink", "Beer") || noDrinkSelected){
let where = Object.assign({}, whereBase, {style: {}, AND: <any>[]});
let where = Object.assign({}, whereBase, {style: {}, OR: <any>[]});
// Beer styles
if(searchParams.has("beerstyle")){
@@ -62,8 +62,14 @@ export async function findDrinksFromSearch(searchParams: URLSearchParams) : Prom
if(searchParams.has("max-ibu")){
maxibu = Number(searchParams.get("max-ibu"));
}
where.AND.push({ibu: {gte: minibu}});
where.AND.push({ibu: {lte: maxibu}});
where.OR.push({AND: <any>[]})
where.OR[0].AND.push({ibu: {gte: minibu}});
where.OR[0].AND.push({ibu: {lte: maxibu}});
if(minibu == 0){
where.OR.push({ibu: null});
}
result = result.concat(await dbe.beer.findMany({
include: {style: true, manufacturer: true, containers: {include: {section: true, checkouts: true}}},