This is an automated email from the ASF dual-hosted git repository. jihao pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/incubator-pinot.git
The following commit(s) were added to refs/heads/master by this push: new 26330f3 [TE] frontend - harleyjj/alerts - filter alerts by single subscription group despite having multiple subscription groups (#4093) 26330f3 is described below commit 26330f3a2c3309e7cf574e1fff86a1de9fb934ff Author: Harley Jackson <harleyy...@gmail.com> AuthorDate: Thu Apr 11 23:14:53 2019 -0700 [TE] frontend - harleyjj/alerts - filter alerts by single subscription group despite having multiple subscription groups (#4093) --- .../app/pods/manage/alerts/index/controller.js | 30 +++++++++++-- .../app/pods/manage/alerts/index/route.js | 50 ++++++---------------- .../app/pods/manage/explore/route.js | 36 +--------------- 3 files changed, 42 insertions(+), 74 deletions(-) diff --git a/thirdeye/thirdeye-frontend/app/pods/manage/alerts/index/controller.js b/thirdeye/thirdeye-frontend/app/pods/manage/alerts/index/controller.js index 9cec7cd..c658533 100644 --- a/thirdeye/thirdeye-frontend/app/pods/manage/alerts/index/controller.js +++ b/thirdeye/thirdeye-frontend/app/pods/manage/alerts/index/controller.js @@ -281,7 +281,20 @@ export default Controller.extend({ _recalculateFilterKeys(alertsCollection, blockItem) { const filterToPropertyMap = get(this, 'filterToPropertyMap'); // Aggregate all existing values for our target properties in the current array collection - const alertPropsAsKeys = alertsCollection.map(alert => alert[filterToPropertyMap[blockItem.name]]); + let alertPropsAsKeys = []; + // Make sure subscription groups are not bundled for filter parameters + if (blockItem.name === 'subscription') { + alertsCollection.forEach(alert => { + let groups = alert[filterToPropertyMap[blockItem.name]]; + if (groups) { + groups.split(", ").forEach(g => { + alertPropsAsKeys.push(g); + }); + } + }); + } else { + alertPropsAsKeys = alertsCollection.map(alert => alert[filterToPropertyMap[blockItem.name]]); + } // Add 'none' select option if allowed const canInsertNullOption = alertPropsAsKeys.includes(undefined) && blockItem.hasNullOption; if (canInsertNullOption) { alertPropsAsKeys.push('none'); } @@ -312,7 +325,6 @@ export default Controller.extend({ } // Pick up cached alert array for the secondary filters let filteredAlerts = get(this, 'filteredAlerts'); - // If there is a secondary filter present, filter by it, using the keys we've set up in our filter map Object.keys(filterToPropertyMap).forEach((filterKey) => { let filterValueArray = filters[filterKey]; @@ -320,7 +332,19 @@ export default Controller.extend({ let newAlerts = filteredAlerts.filter(alert => { // See 'filterToPropertyMap' in route. For filterKey = 'owner' this would map alerts by alert['createdBy'] = x const targetAlertPropertyValue = alert[filterToPropertyMap[filterKey]]; - const alertMeetsCriteria = targetAlertPropertyValue && filterValueArray.includes(targetAlertPropertyValue); + let alertMeetsCriteria = false; + // In the case for subscription, there can be multiple groups. We just need to match on one + if (filterKey === "subscription") { + if (targetAlertPropertyValue) { + filterValueArray.forEach(val => { + if (targetAlertPropertyValue.includes(val)) { + alertMeetsCriteria = true; + } + }); + } + } else { + alertMeetsCriteria = targetAlertPropertyValue && filterValueArray.includes(targetAlertPropertyValue); + } const isMatchForNone = !alert.hasOwnProperty(filterToPropertyMap[filterKey]) && filterValueArray.includes('none'); return alertMeetsCriteria || isMatchForNone; }); diff --git a/thirdeye/thirdeye-frontend/app/pods/manage/alerts/index/route.js b/thirdeye/thirdeye-frontend/app/pods/manage/alerts/index/route.js index a21c43f..f22ecf3 100644 --- a/thirdeye/thirdeye-frontend/app/pods/manage/alerts/index/route.js +++ b/thirdeye/thirdeye-frontend/app/pods/manage/alerts/index/route.js @@ -66,7 +66,6 @@ export default Route.extend({ } } } - // Perform initial filters for our 'primary' filter types and add counts const user = getWithDefault(get(this, 'session'), 'data.authenticated.name', null); const myAlertIds = user ? this._findAlertIdsByUserGroup(user, model.detectionAlertConfig) : []; @@ -138,7 +137,20 @@ export default Route.extend({ // Fill in select options for these filters ('filterKeys') based on alert properties from model.alerts filterBlocksLocal.filter(block => block.type === 'select').forEach((filter) => { - const alertPropertyArray = model.alerts.map(alert => alert[filterToPropertyMap[filter.name]]); + let alertPropertyArray = []; + // Make sure subscription groups are not bundled for filter parameters + if (filter.name === 'subscription') { + model.alerts.forEach(alert => { + let groups = alert[filterToPropertyMap[filter.name]]; + if (groups) { + groups.split(", ").forEach(g => { + alertPropertyArray.push(g); + }); + } + }); + } else { + alertPropertyArray = model.alerts.map(alert => alert[filterToPropertyMap[filter.name]]); + } const filterKeys = [ ...new Set(powerSort(alertPropertyArray, null))]; // Add filterKeys prop to each facet or filter block Object.assign(filter, { filterKeys }); @@ -176,40 +188,6 @@ export default Route.extend({ }, /** - * The yaml filters formatter. Convert filters in the yaml file in to a legacy filters string - * For example, filters = { - * "country": ["us", "cn"], - * "browser": ["chrome"] - * } - * will be convert into "country=us;country=cn;browser=chrome" - * - * @method _formatYamlFilter - * @param {Map} filters multimap of filters - * @return {String} - formatted filters string - */ - _formatYamlFilter(filters) { - if (filters){ - const filterStrings = []; - Object.keys(filters).forEach( - function(filterKey) { - const filter = filters[filterKey]; - if (filter && Array.isArray(filter)) { - filter.forEach( - function (filterValue) { - filterStrings.push(filterKey + '=' + filterValue); - } - ); - } else { - filterStrings.push(filterKey + '=' + filter); - } - } - ); - return filterStrings.join(';'); - } - return ''; - }, - - /** * A local helper to find "Alerts I subscribe to" * @method _findAlertIdsByUserGroup * @param {String} user - current logged in user's email alias diff --git a/thirdeye/thirdeye-frontend/app/pods/manage/explore/route.js b/thirdeye/thirdeye-frontend/app/pods/manage/explore/route.js index a9e2c64..1f16034 100644 --- a/thirdeye/thirdeye-frontend/app/pods/manage/explore/route.js +++ b/thirdeye/thirdeye-frontend/app/pods/manage/explore/route.js @@ -98,39 +98,5 @@ export default Route.extend({ metricUrn: get(this, 'metricUrn'), metricUrnList: get(this, 'metricUrnList') ? get(this, 'metricUrnList') : [] }); - }, - - /** - * The yaml filters formatter. Convert filters in the yaml file in to a legacy filters string - * For example, filters = { - * "country": ["us", "cn"], - * "browser": ["chrome"] - * } - * will be convert into "country=us;country=cn;browser=chrome" - * - * @method _formatYamlFilter - * @param {Map} filters multimap of filters - * @return {String} - formatted filters string - */ - _formatYamlFilter(filters) { - if (filters){ - const filterStrings = []; - Object.keys(filters).forEach( - function(filterKey) { - const filter = filters[filterKey]; - if (filter && Array.isArray(filter)) { - filter.forEach( - function (filterValue) { - filterStrings.push(filterKey + '=' + filterValue); - } - ); - } else { - filterStrings.push(filterKey + '=' + filter); - } - } - ); - return filterStrings.join(';'); - } - return ''; - } + } }); --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org For additional commands, e-mail: commits-h...@pinot.apache.org