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



##########
File path: 
thirdeye/thirdeye-frontend/app/pods/components/composite-anomalies/parent-anomalies/component.js
##########
@@ -0,0 +1,120 @@
+/*
+ * Parent Anomalies Component
+ *
+ * Display a table which contains 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 moment from 'moment';
+import config from 'thirdeye-frontend/config/environment';
+
+let data = [];
+
+/*
+ *  convert animaly 'start' and 'end' into an object to be used by template: 
'custom/composite-animalies-table/start-duration'
+ */
+const getAnomaliesStartDuration = (start, end) => {
+  return {
+    startTime: start,
+    endTime: end,
+    duration: moment.duration(end - start).asHours() + ' hours'
+  };
+};
+
+/*
+ *  convert list of anonalies object in to a objects
+ */
+const getAnomaliesDetails = (details) => {
+  const detailsObject = [];
+  Object.entries(details).forEach((detail) => {
+    detailsObject.push({ name: detail[0], count: detail[1] });
+  });
+
+  return detailsObject;
+};
+
+/*
+    map feedback onto a feedbackObject to be use in the feedback dropdown
+    This code assumes that `feedback` is either null when it has not be set, 
or an integer that can then be mapped to feedbackOptions.
+*/
+const getFeedback = (feedback = 0) => {
+  const feedbackOptions = [
+    'Not reviewed yet',
+    'Yes - unexpected',
+    'Expected temporary change',
+    'Expected permanent change',
+    'No change observed'
+  ];
+  const selectedFeedback = feedback ? feedbackOptions[feedback] : 
feedbackOptions[0];
+
+  const feedbackObject = {
+    options: feedbackOptions,
+    selected: selectedFeedback
+  };
+
+  return feedbackObject;
+};
+
+export default Component.extend({
+  didReceiveAttrs() {
+    data = this.data;
+  },
+  tagName: 'section',
+  customClasses: {
+    table: 'parent-anomalies-table'
+  },
+  title: 'Composite Anomalies', // Default Header if no title is passed in.
+  noRecords: 'No Composite Anomalies found',
+  tableData: computed('data', () => {
+    let computedTableData = [];
+
+    if (data && data.length > 0) {
+      data.map((d) => {
+        const row = {
+          startDuration: getAnomaliesStartDuration(d.startTime, d.endTime),

Review comment:
       well. the column contains both the 'start Time' and the 'duration'. 
naming it `anomalyDuration` would miss that `startTime` is part of it




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