This is an automated email from the ASF dual-hosted git repository.
xhsun 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 9ec6b5b [TE] frontend - harleyjj/manage-alerts - remove old alerts
from results and display type correctly (#3968)
9ec6b5b is described below
commit 9ec6b5b5f3e8bfdb43d3c1739f85d2c49fe792d7
Author: Harley Jackson <[email protected]>
AuthorDate: Wed Mar 13 18:54:44 2019 -0700
[TE] frontend - harleyjj/manage-alerts - remove old alerts from results and
display type correctly (#3968)
---
.../app/mirage/endpoints/selfserve.js | 17 ++++--
.../app/mirage/factories/alert.js | 60 ++++++++++++----------
.../self-serve-alert-details/template.hbs | 12 ++---
.../app/pods/manage/alerts/index/route.js | 39 ++++++--------
.../tests/acceptance/edit-alert-test.js | 39 --------------
.../acceptance/self-serve-alert-tuning-test.js | 32 +-----------
6 files changed, 64 insertions(+), 135 deletions(-)
diff --git a/thirdeye/thirdeye-frontend/app/mirage/endpoints/selfserve.js
b/thirdeye/thirdeye-frontend/app/mirage/endpoints/selfserve.js
index 957237a..64ad90c 100644
--- a/thirdeye/thirdeye-frontend/app/mirage/endpoints/selfserve.js
+++ b/thirdeye/thirdeye-frontend/app/mirage/endpoints/selfserve.js
@@ -76,7 +76,7 @@ export default function (server) {
/**
* Returns the email config by id
*/
- server.get('/thirdeye/email/function/:id', (schema, request) => {
+ server.get('/thirdeye/email/function/:id', () => {
return [alertConfig[1]];
});
@@ -160,7 +160,7 @@ export default function (server) {
/**
* Mocks a list of alerts, displayed in the /manage/alerts page
*/
- server.get('/thirdeye/entity/ANOMALY_FUNCTION', (schema) => {
+ server.get('/yaml/list', (schema) => {
return schema.alerts.all().models;
});
@@ -215,9 +215,16 @@ export default function (server) {
});
/**
- * get request for list yaml configs
+ * get request for detection config
*/
- server.get('/yaml/list', () => {
+ server.get('/detection/:id', () => {
return [];
- })
+ });
+
+ /**
+ * get request for subscription groups of given alert
+ */
+ server.get('/detection/subscription-groups/:id', () => {
+ return [];
+ });
}
diff --git a/thirdeye/thirdeye-frontend/app/mirage/factories/alert.js
b/thirdeye/thirdeye-frontend/app/mirage/factories/alert.js
index 0d00e9c..5cdfcc0 100644
--- a/thirdeye/thirdeye-frontend/app/mirage/factories/alert.js
+++ b/thirdeye/thirdeye-frontend/app/mirage/factories/alert.js
@@ -1,33 +1,39 @@
import { Factory } from 'ember-cli-mirage';
export default Factory.extend({
- version: 1,
- createdBy: null,
- updatedBy: null,
- collection(i) { return `test_collection_${i+1}`; },
- functionName(i) { return `test_function_${i+1}`; },
metric(i) { return `test_metric_${i+1}`; },
- metrics(i) { return [`test_metric_${i+1}`]; },
- properties(i) { return `test_properties_${i+1}`; },
- cron(i) { return `test_cron_${i+1}`; },
- metricFunction: "SUM",
- type: "WEEK_OVER_WEEK_RULE",
- isActive: true,
- globalMetric: null,
- globalMetricFilters: null,
- frequency: {
- size: 1,
- unit: "DAYS"
+ functionName(i) { return `test_function_${i+1}`; },
+ createdBy : null,
+ detectionName(i) { return `test_function_${i+1}`; },
+ rules : [ {
+ detection : [ {
+ name : "detection_rule_2",
+ type : "ABSOLUTE_CHANGE_RULE",
+ params : {
+ offset : "wo1w",
+ change : 1,
+ pattern : null
+ }
+ }, {
+ name : "filter_rule_2",
+ type : "ALGORITHM_FILTER",
+ params : {
+ configuration : {
+ bucketPeriod : null
+ }
+ }
+ } ]
+ } ],
+ filters : {
+ dimensionName1 : [ "dimensionValue1", "dimensionValue2" ],
+ dimensionName2 : [ "dimensionValue3" ]
},
- bucketSize: 1,
- bucketUnit: "DAYS",
- windowSize: 7,
- windowUnit: "DAYS",
- metricId: 0,
- dataFilter: null,
- alertFilter: null,
- anomalyMergeConfig: null,
- requiresCompletenessCheck: true,
- topicMetric: "test_metric",
- toCalculateGlobalMetric: false
+ pipelineType : "Composite",
+ isActive : true,
+ dataset : null,
+ dimensionExploration : {
+ dimensions : [ "dimensionName" ],
+ minContribution : 0.05,
+ k : 10
+ }
});
diff --git
a/thirdeye/thirdeye-frontend/app/pods/components/self-serve-alert-details/template.hbs
b/thirdeye/thirdeye-frontend/app/pods/components/self-serve-alert-details/template.hbs
index 560fa7c..b4548e7 100644
---
a/thirdeye/thirdeye-frontend/app/pods/components/self-serve-alert-details/template.hbs
+++
b/thirdeye/thirdeye-frontend/app/pods/components/self-serve-alert-details/template.hbs
@@ -12,15 +12,9 @@
{{/if}}
</div>
{{#if (eq displayMode "list")}}
- {{#if alertData.isNewPipeline}}
- {{#link-to "manage.explore" alertData.id}}
- <div class="te-search-results__title-name"
title={{alertData.functionName}}>{{alertData.functionName}}</div>
- {{/link-to}}
- {{else}}
- {{#link-to "manage.alert" alertData.id}}
- <div class="te-search-results__title-name"
title={{alertData.functionName}}>{{alertData.functionName}}</div>
- {{/link-to}}
- {{/if}}
+ {{#link-to "manage.explore" alertData.id}}
+ <div class="te-search-results__title-name"
title={{alertData.functionName}}>{{alertData.functionName}}</div>
+ {{/link-to}}
{{/if}}
</div>
</div>
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 34ce8f0..df31451 100644
--- a/thirdeye/thirdeye-frontend/app/pods/manage/alerts/index/route.js
+++ b/thirdeye/thirdeye-frontend/app/pods/manage/alerts/index/route.js
@@ -1,7 +1,6 @@
import { hash } from 'rsvp';
import Route from '@ember/routing/route';
import fetch from 'fetch';
-import { isPresent } from '@ember/utils';
import { get, getWithDefault } from '@ember/object';
import { inject as service } from '@ember/service';
import { checkStatus } from 'thirdeye-frontend/utils/utils';
@@ -24,7 +23,6 @@ export default Route.extend({
model() {
return hash({
- rawAlerts: fetch('/thirdeye/entity/ANOMALY_FUNCTION').then(checkStatus),
subscriberGroups:
fetch('/thirdeye/entity/ALERT_CONFIG').then(checkStatus),
applications: fetch('/thirdeye/entity/APPLICATION').then(checkStatus),
detectionAlertConfig:
fetch('/thirdeye/entity/DETECTION_ALERT_CONFIG').then(checkStatus),
@@ -34,23 +32,6 @@ export default Route.extend({
afterModel(model) {
this._super(model);
- // Work only with valid alerts - with metric association
- let alerts = model.rawAlerts.filter(alert => isPresent(alert.metric));
-
- // Iterate through config groups to enhance all alerts with extra
properties (group name, application)
- for (let config of model.subscriberGroups) {
- let groupFunctionIds = config.emailConfig &&
config.emailConfig.functionIds ? config.emailConfig.functionIds : [];
- for (let id of groupFunctionIds) {
- let foundAlert = alerts.find(alert => alert.id === id);
- if (foundAlert) {
- Object.assign(foundAlert, {
- application: config.application,
- group: foundAlert.group ? foundAlert.group + ", " + config.name :
config.name
- });
- }
- }
- }
-
// format Yaml configs
const yamlAlerts = model.detectionYaml;
for (let yamlAlert of yamlAlerts) {
@@ -65,7 +46,7 @@ export default Route.extend({
Object.assign(yamlAlert, {
functionName: yamlAlert.detectionName,
collection: yamlAlert.dataset,
- type: yamlAlert.pipelineType,
+ type: this._detectionType(yamlAlert),
exploreDimensions: dimensions,
filters: this._formatYamlFilter(yamlAlert.filters),
isNewPipeline: true
@@ -86,8 +67,7 @@ export default Route.extend({
}
}
- // concat legacy alerts and yaml alerts
- alerts = alerts.concat(yamlAlerts);
+ const alerts = yamlAlerts;
// Perform initial filters for our 'primary' filter types and add counts
const user = getWithDefault(get(this, 'session'),
'data.authenticated.name', null);
@@ -99,8 +79,7 @@ export default Route.extend({
Object.assign(model, { alerts, ownedAlerts, subscribedAlerts, totalCounts
});
},
- setupController(controller, model, transition) {
- const { queryParams } = transition;
+ setupController(controller, model) {
// This filter category is "global" in nature. When selected, they reset
the rest of the filters
const filterBlocksGlobal = [
@@ -187,6 +166,18 @@ export default Route.extend({
},
/**
+ * Grab detection type if available, else return yamlAlert.pipelineType
+ */
+ _detectionType(yamlAlert) {
+ if (yamlAlert.rules && Array.isArray(yamlAlert.rules) &&
yamlAlert.rules.length > 0) {
+ if (yamlAlert.rules[0].detection &&
Array.isArray(yamlAlert.rules[0].detection) &&
yamlAlert.rules[0].detection.length > 0) {
+ return yamlAlert.rules[0].detection[0].type;
+ }
+ }
+ return yamlAlert.pipelineType;
+ },
+
+ /**
* The yaml filters formatter. Convert filters in the yaml file in to a
legacy filters string
* For example, filters = {
* "country": ["us", "cn"],
diff --git a/thirdeye/thirdeye-frontend/tests/acceptance/edit-alert-test.js
b/thirdeye/thirdeye-frontend/tests/acceptance/edit-alert-test.js
deleted file mode 100644
index b440002..0000000
--- a/thirdeye/thirdeye-frontend/tests/acceptance/edit-alert-test.js
+++ /dev/null
@@ -1,39 +0,0 @@
-import { module, test } from 'qunit';
-import { setupApplicationTest } from 'ember-qunit';
-import { visit, fillIn, click, currentURL } from '@ember/test-helpers';
-import { selfServeConst } from 'thirdeye-frontend/tests/utils/constants';
-import $ from 'jquery';
-
-module('Acceptance | edit alert', function(hooks) {
- setupApplicationTest(hooks);
-
- test(`visiting ${selfServeConst.EDIT_LINK} and checking that fields render
correctly and edit is successful`, async (assert) => {
- const alert = server.create('alert');
- const editSuccessMsg = `Edit Alert Success! You have successfully edited
alert ${alert.id}`;
- const editNotificationButtonText = 'Edit Notification Settings';
-
- await visit(`/manage/alert/${alert.id}/edit`);
-
- assert.equal(
- currentURL(),
- `/manage/alert/1/edit`,
- 'correctly redirects to edit alerts page'
- );
- assert.equal(
- $(selfServeConst.ALERT_NAME_INPUT).get(0).value,
- 'test_function_1',
- 'alert name is correct');
- assert.ok(
- $(`button:contains(${editNotificationButtonText})`).get(0),
- 'Subscription group button renders ok');
-
-/* TODO: Test completion needed for new notification settings modal
- await fillIn(selfServeConst.ALERT_NAME_INPUT,
selfServeConst.NEW_FUNC_NAME);
- await click(selfServeConst.STATUS_TOGGLER);
- await click(selfServeConst.SUBMIT_BUTTON);
- assert.ok(
-
$(selfServeConst.IMPORT_SUCCESS).get(0).innerText.includes(editSuccessMsg),
- 'after edit, alert is saved successfully');
-*/
- });
-});
diff --git
a/thirdeye/thirdeye-frontend/tests/acceptance/self-serve-alert-tuning-test.js
b/thirdeye/thirdeye-frontend/tests/acceptance/self-serve-alert-tuning-test.js
index ef520ea..55ccfcf 100644
---
a/thirdeye/thirdeye-frontend/tests/acceptance/self-serve-alert-tuning-test.js
+++
b/thirdeye/thirdeye-frontend/tests/acceptance/self-serve-alert-tuning-test.js
@@ -26,6 +26,7 @@ module('Acceptance | tune alert settings', function(hooks) {
server.createList('alert', 5);
await visit(`/manage/alerts`);
const $targetAlertLink =
$(`${selfServeConst.RESULTS_LINK}:contains(${alertLinkTitle})`);
+ const problem = $(selfServeConst.RESULTS_TITLE).get(0).innerText.trim();
// Verify default search results
assert.equal(
@@ -33,37 +34,6 @@ module('Acceptance | tune alert settings', function(hooks) {
'Alerts (5)',
'Number of alerts displayed and title are correct.'
);
-
- // Click into Alert Page for first listed alert
- await click($targetAlertLink.get(0));
- const alertPropsElementArray =
Object.values($(selfServeConst.ALERT_PROPS_ITEM)).filter(el => el.nodeName
==='DIV');
- const alertPropLabelsArray = alertPropsElementArray.map(el =>
el.innerText.trim());
-
- // Verify transition to Alert Page
- assert.ok(
- currentURL().includes(`/manage/alert/1/explore?duration=3m`),
- 'Navigation to alert page succeeded'
- );
-
- // Verify all alert property labels are present
- assert.ok(
- alertPropLabelsArray.join() === alertProps.join(),
- 'All needed labels are displayed in header for Alert Page'
- );
-
- // Change the default date range, confirm it is cached in tuning page
- await click($(selfServeConst.RANGE_PILL_SELECTOR_TRIGGER).get(0));
- await click($(selfServeConst.RANGE_PILL_PRESET_OPTION).get(0));
- const urlCustomTune = currentURL().replace('explore', 'tune');
-
- // Navigate to tuning page, verify time range options in URL are the same
- await click($(selfServeConst.LINK_TUNE_ALERT).get(0));
-
- assert.equal(
- currentURL(),
- urlCustomTune,
- 'In transition to tuning page, the user-selected custom date range was
persisted'
- );
});
/**
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]