zhangloo333 commented on a change in pull request #6333: URL: https://github.com/apache/incubator-pinot/pull/6333#discussion_r556188129
########## File path: thirdeye/thirdeye-frontend/app/pods/components/rootcause-metrics/component.js ########## @@ -82,74 +92,91 @@ export default Component.extend({ * ] * } */ - links: computed( - 'entities', - function() { - const { entities } = getProperties(this, 'entities'); - let metricUrlMapping = {}; - - filterPrefix(Object.keys(entities), 'thirdeye:metric:') - .forEach(urn => { - const attributes = entities[urn].attributes; - const { externalUrls = [] } = attributes; - let urlArr = []; - - // Add the list of urls for each url type - externalUrls.forEach(urlLabel => { - urlArr.push({ - [urlLabel]: attributes[urlLabel][0] // each type should only have 1 url - }); - }); - - // Map all the url lists to a metric urn - metricUrlMapping[urn] = urlArr; + links: computed('entities', function () { + const { entities } = getProperties(this, 'entities'); + let metricUrlMapping = {}; + + filterPrefix(Object.keys(entities), 'thirdeye:metric:').forEach((urn) => { + const attributes = entities[urn].attributes; + const { externalUrls = [] } = attributes; + let urlArr = []; + + // Add the list of urls for each url type + externalUrls.forEach((urlLabel) => { + urlArr.push({ + [urlLabel]: attributes[urlLabel][0] // each type should only have 1 url }); + }); Review comment: This seems like a map function. ``` const urlArr = externalUrls.map((urlLabel)=>{return [urlLabel]: attributes[urlLabel][0]}) ``` ########## File path: thirdeye/thirdeye-frontend/app/pods/components/rootcause-metrics/component.js ########## @@ -203,17 +265,21 @@ export default Component.extend({ * Updates the currently selected urns based on user selection on the table * @param {Object} e */ - displayDataChanged (e) { - if (_.isEmpty(e.selectedItems)) { return; } + displayDataChanged(e) { + if (_.isEmpty(e.selectedItems)) { + return; + } const { selectedUrns, onSelection } = getProperties(this, 'selectedUrns', 'onSelection'); - if (!onSelection) { return; } + if (!onSelection) { + return; + } Review comment: You can optimize the code. if(_.isEmpty(e.selectedItems) || !onSelection) return ########## File path: thirdeye/thirdeye-frontend/app/pods/components/rootcause-metrics/component.js ########## @@ -189,10 +251,10 @@ export default Component.extend({ * @type {Array} */ preselectedItems: computed({ - get () { + get() { return []; }, - set () { + set() { // ignore } }), Review comment: it's better to add TODO and Jira Ticket to trace. ########## File path: thirdeye/thirdeye-frontend/app/pods/components/rootcause-metrics/component.js ########## @@ -65,10 +56,29 @@ export default Component.extend({ */ onSelection: null, // function (Set, state) + context: null, + + compareMode: null, // "" Review comment: It is better to add the type to avoid the type issue. ########## File path: thirdeye/thirdeye-frontend/app/pods/services/rootcause-aggregates-cache/service.js ########## @@ -68,34 +67,34 @@ export default Service.extend({ // group by metrics and offsets const groupedByUrn = [...missing] - .map(urn => toAbsoluteUrn(urn, requestContext.compareMode)) - .map(urn => { return { urn, base: toMetricUrn(urn), offset: urn.split(':')[2] }; }) + .map((urn) => toAbsoluteUrn(urn, requestContext.compareMode)) + .map((urn) => { + return { urn, base: toMetricUrn(urn), offset: urn.split(':')[2] }; + }) Review comment: Why use two maps function here? One map could finish the result and will increase efficiency. ########## File path: thirdeye/thirdeye-frontend/app/pods/services/rootcause-aggregates-cache/service.js ########## @@ -28,7 +23,7 @@ export default Service.extend({ init() { this._super(...arguments); - this.setProperties({aggregates: {}, context: {}, pending: new Set(), errors: new Set()}); + this.setProperties({ aggregates: {}, context: {}, pending: new Set(), errors: new Set() }); Review comment: Why not give aggregates value of `{}` property level? ---------------------------------------------------------------- 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