tejasajmera commented on a change in pull request #6345:
URL: https://github.com/apache/incubator-pinot/pull/6345#discussion_r544653609



##########
File path: 
thirdeye/thirdeye-frontend/app/pods/custom/composite-animalies-table/anomalies-list/template.hbs
##########
@@ -0,0 +1,4 @@
+

Review comment:
       Empty line?

##########
File path: 
thirdeye/thirdeye-frontend/app/pods/custom/composite-animalies-table/start-duration/template.hbs
##########
@@ -0,0 +1,9 @@
+

Review comment:
       Empty line?

##########
File path: 
thirdeye/thirdeye-frontend/app/pods/custom/composite-animalies-table/resolution/template.hbs
##########
@@ -0,0 +1,12 @@
+

Review comment:
       Empty line?

##########
File path: 
thirdeye/thirdeye-frontend/app/pods/components/composite-anomalies/parent-anomalies/component.js
##########
@@ -0,0 +1,117 @@
+/*
+ * Parent Anomalies Component
+ *
+ * Display a table containing composite anomalies
+ * @module composite-anomalies/parent-anomalies
+ * @property {string} title   - Heading to use on the table
+ * @property {object[]} data  - [required] array of composite anomalies objects
+ *
+ * @example
+ * {{composite-anomalies/parent-anomalies title=<title> data=<data>}}
+ *
+ * @exports composite-anomalies/parent-anomalies
+ */
+
+import Component from '@ember/component';
+import { computed } from '@ember/object';
+import { A as EmberArray } from '@ember/array';
+
+import moment from 'moment';
+import config from 'thirdeye-frontend/config/environment';
+import * as anomalyUtil from 'thirdeye-frontend/utils/anomaly';
+
+const TABLE_COLUMNS = [
+  {
+    template: 'custom/composite-animalies-table/start-duration',
+    propertyName: 'startDuration',
+    title: `Start / Duration (${moment.tz([2012, 5], 
config.timeZone).format('z')})`
+  },
+  {
+    template: 'custom/composite-animalies-table/anomalies-list',
+    propertyName: 'details',
+    title: 'Anomalies details'
+  },
+  {
+    component: 'custom/composite-animalies-table/resolution',
+    propertyName: 'feedback',
+    title: 'Feedback '
+  }
+];
+
+export default Component.extend({
+  data: EmberArray(),
+  tagName: 'section',
+  customClasses: {
+    table: 'composite-anomalies-table'
+  },
+  title: 'Composite Anomalies', // Default Header if no title is passed in.
+  noRecords: 'No Composite Anomalies found',
+  tableData: computed('data', function () {
+    let computedTableData = [];
+
+    if (this.data && this.data.length > 0) {
+      this.data.map((d) => {
+        const row = {
+          startDuration: this.getAnomaliesStartDuration(d.startTime, 
d.endTime),
+          anomaliesDetails: this.getAnomaliesDetails(d.details),
+          feedback: this.getFeedback(d.feedback)
+        };
+        computedTableData.push(row);
+      });
+    }
+    return computedTableData;
+  }),
+  tableColumns: TABLE_COLUMNS,
+  /*
+   *  convert anomaly 'start' and 'end' into an object to be used by template: 
'custom/composite-animalies-table/start-duration'
+   *
+   * @param {Number} start
+   * The start time in milliseconds.
+   * @param {Number} end
+   * The end time in milliseconds
+   *
+   * @returns {Object}
+   * Description of the object.
+   */
+  getAnomaliesStartDuration: (start, end) => {
+    return {
+      startTime: start,
+      endTime: end,
+      duration: moment.duration(end - start).asHours() + ' hours'
+    };
+  },
+  /*
+   *  convert list of anonalies object in to an array of objects to be used by 
template: 'custom/composite-animalies-table/anomalies-list'
+   *
+   * @param {Object} details
+   * The object containing the list of anomalies and their count.
+   *
+   * @returns {Array}
+   * Description of the object.
+   */
+  getAnomaliesDetails: (anomalies) => {
+    return Object.entries(anomalies).reduce((anomalyList, anomalyDetails) => {
+      anomalyList.push({ name: anomalyDetails[0], count: anomalyDetails[1] });
+      return anomalyList;
+    }, []);
+  },
+  /*
+   * return feedbackObject with pre-selected 'feedback' to be use in the 
feedback dropdown
+   *
+   * @param {String} feedback
+   * The object containing the list of anomalies and their count.
+   *
+   * @returns {Object} feedbackObject
+   * Description of the object.
+   */
+  getFeedback: (feedback) => {
+    const selectedFeedback = feedback
+      ? anomalyUtil.anomalyResponseObj.find((f) => f.value === feedback)
+      : anomalyUtil.anomalyResponseObj[0];
+    const feedbackObject = {
+      options: anomalyUtil.anomalyResponseObj.mapBy('name'),
+      selected: selectedFeedback ? selectedFeedback.name : 
anomalyUtil.anomalyResponseObj[0].name
+    };
+    return feedbackObject;

Review comment:
       Minor. Don't need a temp. variable `feedbackObject`, you can directly 
return the object.
   
   Also, a feedback on structuring of functions. For readability purposes, I 
insert a blank line between constant declarations, processing logic and return 
statements.

##########
File path: 
thirdeye/thirdeye-frontend/app/pods/components/composite-anomalies/parent-anomalies/component.js
##########
@@ -0,0 +1,117 @@
+/*
+ * Parent Anomalies Component
+ *
+ * Display a table containing composite anomalies
+ * @module composite-anomalies/parent-anomalies
+ * @property {string} title   - Heading to use on the table
+ * @property {object[]} data  - [required] array of composite anomalies objects
+ *
+ * @example
+ * {{composite-anomalies/parent-anomalies title=<title> data=<data>}}
+ *
+ * @exports composite-anomalies/parent-anomalies
+ */
+
+import Component from '@ember/component';
+import { computed } from '@ember/object';
+import { A as EmberArray } from '@ember/array';
+
+import moment from 'moment';
+import config from 'thirdeye-frontend/config/environment';
+import * as anomalyUtil from 'thirdeye-frontend/utils/anomaly';
+
+const TABLE_COLUMNS = [
+  {
+    template: 'custom/composite-animalies-table/start-duration',
+    propertyName: 'startDuration',
+    title: `Start / Duration (${moment.tz([2012, 5], 
config.timeZone).format('z')})`
+  },
+  {
+    template: 'custom/composite-animalies-table/anomalies-list',
+    propertyName: 'details',
+    title: 'Anomalies details'
+  },
+  {
+    component: 'custom/composite-animalies-table/resolution',
+    propertyName: 'feedback',
+    title: 'Feedback '
+  }
+];
+
+export default Component.extend({
+  data: EmberArray(),
+  tagName: 'section',
+  customClasses: {
+    table: 'composite-anomalies-table'
+  },
+  title: 'Composite Anomalies', // Default Header if no title is passed in.
+  noRecords: 'No Composite Anomalies found',
+  tableData: computed('data', function () {
+    let computedTableData = [];

Review comment:
       This should be a `const` so that it is not reassigned to something else 
unintentionally.




----------------------------------------------------------------
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

Reply via email to