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



##########
File path: thirdeye/thirdeye-frontend/app/utils/anomalies-tree-parser.js
##########
@@ -0,0 +1,563 @@
+import { isEmpty } from "@ember/utils";
+import { set } from "@ember/object";
+import moment from "moment";
+
+const CLASSIFICATIONS = {
+  METRICS: {
+    KEY: "metrics",
+    COMPONENT_PATH: "entity-metrics",
+    DEFAULT_TITLE: "Metric Anomalies"
+  },
+  GROUPS: {
+    KEY: "groups",
+    COMPONENT_PATH: "entity-groups",
+    DEFAULT_TITLE: "ENTITY:"
+  },
+  ENTITIES: {
+    KEY: "entities",
+    COMPONENT_PATH: "parent-anomalies",
+    DEFAULT_TITLE: "Entity"
+  }
+};
+const BREADCRUMB_TIME_DISPLAY_FORMAT = "MMM D HH:mm";
+
+/**
+ * Format the timestamp into the form to be shown in the breadcrumb
+ *
+ * @param {Number} timestamp
+ *   The timestamp of anomaly creation time in milliseconds
+ *
+ * @returns {String}
+ *   Formatted timestamp. Example of the required format - "Sep 15 16:49 EST"
+ */
+const getFormattedBreadcrumbTime = timestamp => {
+  const zoneName = moment.tz.guess();
+  const timeZoneAbbreviation = moment.tz(zoneName).zoneAbbr();
+
+  return `${moment(timestamp).format(
+    BREADCRUMB_TIME_DISPLAY_FORMAT
+  )} ${timeZoneAbbreviation}`;
+};
+
+/**
+ * Parse the anomalies generated by the composite alert to populate 
parent-anomalies table with relevent details about
+ * children for each anomaly.
+ *
+ * @param {Array<Object>} input
+ *   The anomalies for composite alert.
+ *
+ * @returns {Array<Object>}
+ *   Parsed out contents to populate parent-anomalies table
+ */
+const populateParentAnomaliesTable = input => {
+  const output = [];
+
+  for (const entry of input) {
+    const { id, startTime, endTime, feedback, children } = entry;
+    const entryOutput = {
+      id,
+      startTime,
+      endTime,
+      feedback
+    };
+
+    const details = {};
+    let item;
+    if (children.length > 0) {
+      for (const child of children) {
+        const { metric, properties: { subEntityName } = {} } = child;
+
+        if (!isEmpty(metric)) {

Review comment:
       Will do.




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