Skip to content

Commit

Permalink
Updating filtercache with exception handler to log errors and not cra…
Browse files Browse the repository at this point in the history
…sh; added further checks
  • Loading branch information
kohsah committed Apr 20, 2018
1 parent e58c9ad commit be0e867
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 11 deletions.
23 changes: 14 additions & 9 deletions filtercache.js
Original file line number Diff line number Diff line change
Expand Up @@ -255,16 +255,21 @@ function remapKeyWords(filterValue) {
const KW = "keyword";
const KW_THRESHOLD = 50;
var filterMap = pick(filterValue, ["name", "label"]);
if(!apputils.objectIsEmpty(filterMap)) {
if (filterValue[KW].length <= KW_THRESHOLD) {
filterMap[KW] = filterValue[KW];
} else {
filterMap[KW] = apputils.randomNItemsFromArray(
filterValue[KW],
KW_THRESHOLD
);
try {
if(!apputils.objectIsEmpty(filterValue)) {
if (filterValue.hasOwnProperty(KW)) {
if (filterValue[KW].length <= KW_THRESHOLD) {
filterMap[KW] = filterValue[KW];
} else {
filterMap[KW] = apputils.randomNItemsFromArray(
filterValue[KW],
KW_THRESHOLD
);
}
}
}

} catch (error) {
logr.error("Exception in remapKeywords ", error);
}
return filterMap;
}
Expand Down
Loading

0 comments on commit be0e867

Please sign in to comment.