浏览代码

HUE-4019 [impala] Always fetch the logs on check status

Also update status of queries that failed
Romain Rigaux 9 年之前
父节点
当前提交
58a3389
共有 1 个文件被更改,包括 28 次插入25 次删除
  1. 28 25
      desktop/libs/notebook/src/notebook/static/notebook/js/notebook.ko.js

+ 28 - 25
desktop/libs/notebook/src/notebook/static/notebook/js/notebook.ko.js

@@ -883,36 +883,39 @@
       }, function (data) {
         if (self.statusForButtons() == 'canceling' || self.status() == 'canceled') {
           // Query was canceled in the meantime, do nothing
-        } else if (data.status == 0) {
-          self.status(data.query_status.status);
+        } else {
           self.getLogs();
 
-          if (self.status() == 'running' || self.status() == 'starting') {
-            self.result.endTime(new Date());
-            if (! notebook.unloaded()) { self.checkStatusTimeout = setTimeout(self.checkStatus, 1000); };
-          }
-          else if (self.status() == 'available') {
-            self.fetchResult(100);
-            self.progress(100);
-            if (self.isSqlDialect() && ! self.result.handle().has_result_set) { // DDL
-              self.ddlNotification(Math.random());
-              if (self.result.handle().has_more_statements) {
-                setTimeout(function () {
-                  self.execute(); // Execute next, need to wait as we disabled fast click
-                }, 1000);
+          if (data.status == 0) {
+            self.status(data.query_status.status);
+
+            if (self.status() == 'running' || self.status() == 'starting') {
+              self.result.endTime(new Date());
+              if (! notebook.unloaded()) { self.checkStatusTimeout = setTimeout(self.checkStatus, 1000); };
+            }
+            else if (self.status() == 'available') {
+              self.fetchResult(100);
+              self.progress(100);
+             if (self.isSqlDialect() && ! self.result.handle().has_result_set) { // DDL
+                self.ddlNotification(Math.random());
+                if (self.result.handle().has_more_statements) {
+                  setTimeout(function () {
+                    self.execute(); // Execute next, need to wait as we disabled fast click
+                  }, 1000);
+                }
+              }
+              if (vm.successUrl()) {
+                window.location.href = vm.successUrl();
               }
             }
-            if (vm.successUrl()) {
-              window.location.href = vm.successUrl();
+            else if (self.status() == 'success') {
+              self.progress(99);
             }
+          } else if (data.status == -3) {
+            self.status('expired');
+          } else {
+            self._ajaxError(data);
           }
-          else if (self.status() == 'success') {
-            self.progress(99);
-          }
-        } else if (data.status == -3) {
-          self.status('expired');
-        } else {
-          self._ajaxError(data);
         }
       }).fail(function (xhr, textStatus, errorThrown) {
         $(document).trigger("error", xhr.responseText || textStatus);
@@ -1447,7 +1450,7 @@
         $.post("/notebook/api/check_status", {
           notebook: ko.mapping.toJSON({id: item.uuid()}),
         }, function (data) {
-          var status = data.status == -3 ? 'expired' : (data.status == 0 ? data.query_status.status : null);
+          var status = data.status == -3 ? 'expired' : (data.status == 0 ? data.query_status.status : 'failed');
           if (status && item.status() != status) {
             item.status(status);
           }