浏览代码

HUE-6840 [notebook] Workaround lack of status flag in Impala profile page

Romain Rigaux 8 年之前
父节点
当前提交
ae948a5af0

+ 1 - 1
desktop/core/src/desktop/templates/hue.mako

@@ -1084,7 +1084,7 @@ ${ smart_unicode(login_modal(request).content) | n,unicode }
         });
 
         huePubSub.subscribe('cluster.config.set.config', function (clusterConfig) {
-          page('/', function() {  page(clusterConfig['main_button_action'].page); });
+          page('/', function() { page(clusterConfig['main_button_action'].page); });
           page('*', function (ctx) {
             console.error('Route not found', ctx);
             self.loadApp('404');

+ 18 - 17
desktop/libs/notebook/src/notebook/static/notebook/js/notebook.ko.js

@@ -1525,27 +1525,25 @@ var EditorViewModel = (function() {
       });
     };
 
-    self.fetchResultSize = function(n) {
-      if (typeof n === 'undefined') {
-        n = 10;
-      }
-
+    self.fetchResultSize = function(n, query_id) {
       $.post("/notebook/api/fetch_result_size", {
         notebook: ko.mapping.toJSON(notebook.getContext()),
         snippet: ko.mapping.toJSON(self.getContext())
       }, function (data) {
-        if (data.status == 0) {
-          if (data.result.rows != null) {
-            self.result.rows(data.result.rows);
-          } else if (self.type() == 'impala' && n > 0) {
-            setTimeout(function () {
-              self.fetchResultSize(n - 1);
-            }, 1000);
+        if (query_id == notebook.id()) { // If still on the same result
+          if (data.status == 0) {
+            if (data.result.rows != null) {
+              self.result.rows(data.result.rows);
+            } else if (self.type() == 'impala' && n > 0) {
+              setTimeout(function () {
+                self.fetchResultSize(n - 1, query_id);
+              }, 1000);
+            }
+          } else if (data.status == 5) {
+            // No supported yet for this snippet
+          } else {
+            //$(document).trigger("error", data.message);
           }
-        } else if (data.status == 5) {
-          // No supported yet for this snippet
-        } else {
-          //$(document).trigger("error", data.message);
         }
       }).fail(function (xhr, textStatus, errorThrown) {
         //$(document).trigger("error", xhr.responseText);
@@ -1578,7 +1576,10 @@ var EditorViewModel = (function() {
               self.progress(100);
               if (self.isSqlDialect()) {
                 if (self.result.handle().has_result_set) {
-                  self.fetchResultSize();
+                  var _query_id = notebook.id();
+                  setTimeout(function () { // Delay until we get IMPALA-5555
+                    self.fetchResultSize(10, _query_id);
+                  }, 2000);
                 } else { // Is DDL
 
                   if (self.lastExecutedStatement()) {