tejasajmera commented on a change in pull request #6514: URL: https://github.com/apache/incubator-pinot/pull/6514#discussion_r568099786
########## File path: thirdeye/thirdeye-frontend/app/utils/utils.js ########## @@ -275,11 +277,68 @@ export function buildBounds(series, baseline, timeseries, useCurrent) { * @param {Array} timeSeries - time series to modify */ export function stripNonFiniteValues(timeSeries) { - return timeSeries.map(value => { - return (isFinite(value) ? value : null); + return timeSeries.map((value) => { + return isFinite(value) ? value : null; }); } +/* + * Detect if the input is in Object form + * + * @param {Any} input + * The input to test. + * + * @returns {Boolean} + * True if input is an object, false otherwise. + */ +export function isObject(input) { + return input instanceof Object && input.constructor === Object; +} + +/* + * Search the input for the existence of the search term + * -Supports searching on following input types - string, integer, float, boolean, object, array + * + * @param {Any} input + * The input to test. + * @param {String} filterStr + * The search term + * + * @returns {Boolean} + * True if the match is found, false otherwise. + */ +export function checkForMatch(input, filterStr) { + if (filterStr === '') { + return true; + } + + if (typeof input === 'string') { + return input.includes(filterStr); + } else if (typeof input === 'number' || typeof input === 'boolean') { + return input.toString().includes(filterStr); + } else if (isObject(input)) { + for (const prop in input) { + if ({}.propertyIsEnumerable.call(input, prop)) { + if (checkForMatch(prop, filterStr) || checkForMatch(input[prop], filterStr)) { Review comment: I can club the `if's` but I don't necessarily agree it leads to improved maintenance or less time understanding the logic, as the logic is not really changed by clubbing the `if's`. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org For additional commands, e-mail: commits-h...@pinot.apache.org