0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2025-12-24 14:12:40 +00:00

"Simplified brewsQuery construction in buildBrewsQuery function"

This commit is contained in:
Víctor Losada Hernández
2024-08-31 18:41:36 +02:00
parent 981e7986ce
commit 3825bcbbfb

View File

@@ -36,15 +36,14 @@ const handleErrorResponse = (res, error, functionName) => {
};
const buildBrewsQuery = (legacy, v3) => {
//first off, no need to include renderers, if all are valid
const brewsQuery = { published: true };
if (legacy === 'true' && v3 === 'true') return { published: true };
const renderers = [];
if (legacy === 'true') renderers.push('legacy');
if (v3 === 'true') renderers.push('V3');
const brewsQuery = { published: true };
brewsQuery.renderer = { $in: renderers };
if (legacy === 'true' && v3 !== 'true') {
brewsQuery.renderer = 'legacy';
} else if (v3 === 'true' && legacy !== 'true') {
brewsQuery.renderer = 'V3';
}
return brewsQuery;
};