Skip to content

Commit

Permalink
chore(jest): improve readability
Browse files Browse the repository at this point in the history
  • Loading branch information
willian-viana committed Oct 20, 2023
1 parent c860d12 commit 84b776d
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions services/get-where-query.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,13 @@ export const getWHEREQuery = (params = {}) => {
const isLastParameter = paramKeys.length - 1 === index;
const hasFilterOption = ['forestType', 'landCategory'].includes(parameter);
const value = hasFilterOption ? 1 : params[parameter];
const polynameMeta = allFilterOptions.find(
const filterOption = allFilterOptions.find(
(pname) => pname.value === params[parameter]
);

const tableKey =
polynameMeta &&
(polynameMeta.tableKey || polynameMeta.tableKeys[dataset || 'annual']);
filterOption &&
(filterOption.tableKey || filterOption.tableKeys[dataset || 'annual']);
let isNumericValue = isNumber(value);

const paramKey = translateParameterKey(parameter, params);
Expand All @@ -70,15 +71,15 @@ export const getWHEREQuery = (params = {}) => {
}

if (
polynameMeta &&
filterOption &&
!hasPrefixIs__ &&
polynameMeta.default &&
polynameMeta.categories
filterOption.default &&
filterOption.categories
) {
WHERE = `${WHERE} AND ${tableKey} ${polynameMeta.comparison || '='} ${
polynameMeta?.dataType === 'keyword'
? `'${polynameMeta?.default}'`
: `${polynameMeta?.default}`
WHERE = `${WHERE} AND ${tableKey} ${filterOption.comparison || '='} ${
filterOption?.dataType === 'keyword'
? `'${filterOption?.default}'`
: `${filterOption?.default}`
}`;
}
}
Expand Down

0 comments on commit 84b776d

Please sign in to comment.