michellethomas commented on a change in pull request #4663: [Request For 
Comments][Explore] Streamlined metric definitions for SQLA and Druid
URL: 
https://github.com/apache/incubator-superset/pull/4663#discussion_r176616167
 
 

 ##########
 File path: superset/assets/javascripts/explore/AdhocMetric.js
 ##########
 @@ -0,0 +1,37 @@
+export default class AdhocMetric {
+  constructor(adhocMetric) {
+    this.column = adhocMetric.column;
+    this.aggregate = adhocMetric.aggregate;
+    this.hasCustomLabel = !!(adhocMetric.hasCustomLabel && adhocMetric.label);
+
+    if (this.hasCustomLabel) {
+      this.label = adhocMetric.label;
+    } else {
+      this.label = this.getDefaultLabel();
+    }
+
+    this.optionName = adhocMetric.optionName ||
+      `metric_${Math.random().toString(36).substring(2, 
15)}_${Math.random().toString(36).substring(2, 15)}`;
+  }
+
+  getDefaultLabel() {
+    return `${this.aggregate || ''}(${(this.column && this.column.column_name) 
|| ''})`;
 
 Review comment:
   When would this.aggregate be null?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to