Browse Source

HUE-6132 [assistant] Send empty risks when there is none

Simplifying logic.
Turn off syntax checker from main hint.
Need to add warning on syntax error.
Romain Rigaux 8 years ago
parent
commit
14bd730

+ 3 - 0
desktop/libs/notebook/src/notebook/connectors/hiveserver2.py

@@ -536,6 +536,9 @@ DROP TABLE IF EXISTS `%(table)s`;
     data = api.query_risk(query=query)
     data = data.get(snippet['type'] + 'Risk', {})
 
+    if data and data == {"riskAnalysis": "", "risk": "low", "riskRecommendation": ""}:
+      data = []
+
     return [{
       'risk': risk.get('risk'),
       'riskAnalysis': risk.get('riskAnalysis'),

+ 6 - 5
desktop/libs/notebook/src/notebook/static/notebook/js/notebook.ko.js

@@ -902,6 +902,7 @@ var EditorViewModel = (function() {
           success: function(data) {
             if (data.status == 0) {
               self.complexity(data.query_complexity);
+              self.hasSuggestion('');
             } else {
               // TODO: Silence errors
               $(document).trigger('error', data.message);
@@ -913,16 +914,16 @@ var EditorViewModel = (function() {
       };
 
       if (self.type() === 'hive' || self.type() === 'impala') {
-        self.delayedStatement.subscribe(function () {
-          self.checkComplexity();
-          self.querySyntaxCompatibility();
-        });
         if (self.statement_raw()) {
           window.setTimeout(function(){
             self.checkComplexity();
-            self.querySyntaxCompatibility();
+            //self.querySyntaxCompatibility();
           }, 2000);
         }
+        self.delayedStatement.subscribe(function () {
+          self.checkComplexity();
+          //self.querySyntaxCompatibility(); Off for now
+        });
       }
     }
 

+ 3 - 3
desktop/libs/notebook/src/notebook/templates/editor_components.mako

@@ -1024,7 +1024,7 @@ from notebook.conf import ENABLE_QUERY_BUILDER, ENABLE_QUERY_SCHEDULING, ENABLE_
     <div class="round-icon empty">&nbsp;</div>
     <!-- ko if: hasSuggestion() == null -->
     <div class="round-icon idle">
-      <i class="fa" data-bind="css: {'fa-spinner fa-spin': compatibilityCheckRunning}"></i>
+      <i class="fa" data-bind="css: {'fa-spinner fa-spin': complexityCheckRunning}"></i>
     </div>
     <!-- /ko -->
 
@@ -1078,8 +1078,8 @@ from notebook.conf import ENABLE_QUERY_BUILDER, ENABLE_QUERY_SCHEDULING, ENABLE_
       <!-- /ko -->
       <!-- /ko -->
     <!-- /ko -->
-    <!-- ko if: hasComplexity() && hasSuggestion() && compatibilitySourcePlatform() === type() && compatibilityTargetPlatform() === type() && suggestion() && !suggestion().parseError() -->
-      <!-- ko if: complexity()[0].risk && (complexity()[0].risk.length === 0 || complexity()[0].risk === 'low') -->
+    <!-- ko if: hasComplexity() -->
+      <!-- ko if: complexity()[0].risk.length === 0 || complexity()[0].risk === 'low' -->
         <div class="round-icon success" data-bind="click: function(){ showOptimizer(! showOptimizer()) }, attr: { 'title': showOptimizer() ? '${ _ko('Close Validator') }' : '${ _ko('Open Validator') }'}">
           <i class="fa fa-check"></i>
         </div>