소스 검색

[metastore] Add refresh of stats to the table details

Johan Ahlen 10 년 전
부모
커밋
31effa8
2개의 변경된 파일31개의 추가작업 그리고 1개의 파일을 삭제
  1. 30 0
      apps/metastore/src/metastore/templates/describe_table.mako
  2. 1 1
      desktop/core/src/desktop/static/desktop/js/assist/assistHelper.js

+ 30 - 0
apps/metastore/src/metastore/templates/describe_table.mako

@@ -172,6 +172,13 @@ ${ assist.assistPanel() }
 <script type="text/html" id="metastore-table-stats">
   <!-- ko with: tableDetails -->
   <h4>${ _('Stats') }
+    <!-- ko if: $root.refreshingTableStats -->
+    <i class="fa fa-refresh fa-spin"></i>
+    <!-- /ko -->
+    <!-- ko ifnot: $root.refreshingTableStats -->
+    <a class="pointer" href="javascript: void(0);" data-bind="click: $root.refreshTableStats"><i class="fa fa-refresh"></i></a>
+    <!-- /ko -->
+    <span data-bind="visible: ! details.stats.COLUMN_STATS_ACCURATE" rel="tooltip" data-placement="top" title="${ _('The column stats for this table are not accurate') }"><i class="fa fa-exclamation-triangle"></i></span>
   </h4>
   <div class="row-fluid">
     <div class="span6">
@@ -571,6 +578,7 @@ ${ assist.assistPanel() }
 
       self.tableDetails = ko.observable();
       self.tableStats = ko.observable();
+      self.refreshingTableStats = ko.observable(false);
       var fetchDetails = function () {
         self.assistHelper.fetchTableDetails({
           sourceType: "hive",
@@ -579,8 +587,10 @@ ${ assist.assistPanel() }
           successCallback: function (data) {
             self.tableDetails(data);
             self.tableStats(data.details.stats);
+            self.refreshingTableStats(false);
           },
           errorCallback: function (data) {
+            self.refreshingTableStats(false);
             console.log('ERRRROR!');
             console.log(data);
           }
@@ -589,6 +599,26 @@ ${ assist.assistPanel() }
 
       fetchDetails();
 
+      self.refreshTableStats = function () {
+        if (self.refreshingTableStats()) {
+          return;
+        }
+        self.refreshingTableStats(true);
+        self.assistHelper.refreshTableStats({
+          tableName: self.activeTable(),
+          databaseName: self.activeDatabase(),
+          sourceType: "hive",
+          successCallback: function (data) {
+            fetchDetails();
+          },
+          errorCallback: function (data) {
+            self.refreshingTableStats(false);
+            console.log('ERRRROR!');
+            console.log(data);
+          }
+        })
+      }
+
       self.isLeftPanelVisible.subscribe(function(newValue) {
         $.totalStorage('spark_left_panel_visible', newValue);
       });

+ 1 - 1
desktop/core/src/desktop/static/desktop/js/assist/assistHelper.js

@@ -188,7 +188,7 @@
       }).fail(options.errorCallback);
     };
 
-    $.post("/" + options.sourceType + "/api/analyze/" + options.databaseName + "/" + options.tableName + "/"  + (options.columnName || ""), function (data) {
+    $.post("/" + (options.sourceType == "hive" ? "beeswax" : options.sourceType) + "/api/analyze/" + options.databaseName + "/" + options.tableName + "/"  + (options.columnName || ""), function (data) {
       if (data.status == 0 && data.watch_url) {
         pollRefresh(data.watch_url);
       } else {