Browse Source

HUE-6331 [editor] Don’t show columns and tables with less than 5% popularity as popular

Johan Ahlen 8 years ago
parent
commit
de9fca21e0

+ 10 - 3
desktop/core/src/desktop/static/desktop/js/assist/assistDbSource.js

@@ -119,7 +119,9 @@ var AssistDbSource = (function () {
           successCallback: function (data) {
             var popularityIndex = {};
             data.top_tables.forEach(function (topTable) {
-              popularityIndex[topTable.name] = topTable.popularity;
+              if (topTable.popularity >= 5) {
+                popularityIndex[topTable.name] = topTable.popularity;
+              }
             });
             var applyPopularity = function () {
               db.entries().forEach(function (entry) {
@@ -134,10 +136,15 @@ var AssistDbSource = (function () {
 
             if (db.loading()) {
               var subscription = db.loading.subscribe(function () {
-                if (subscription) {
+                subscription.dispose();
+                applyPopularity();
+              });
+            } else if (db.entries().length == 0) {
+              var subscription = db.entries.subscribe(function (newEntries) {
+                if (newEntries.length > 0) {
                   subscription.dispose();
+                  applyPopularity();
                 }
-                applyPopularity();
               });
             } else {
               applyPopularity();

+ 7 - 2
desktop/core/src/desktop/static/desktop/js/sqlAutocompleter3.js

@@ -58,8 +58,13 @@ var AutocompleteResults = (function () {
 
   var adjustWeightsBasedOnPopularity = function(suggestions, totalPopularity) {
     suggestions.forEach(function (suggestion) {
-      suggestion.details.popularity.relativePopularity = Math.round(100 * suggestion.details.popularity.popularity / totalPopularity);
-      suggestion.weightAdjust = suggestion.details.popularity.relativePopularity;
+      var relativePopularity = Math.round(100 * suggestion.details.popularity.popularity / totalPopularity);
+      if (relativePopularity < 5) {
+        suggestion.popular(false);
+      } else {
+        suggestion.details.popularity.relativePopularity = Math.round(100 * suggestion.details.popularity.popularity / totalPopularity);
+        suggestion.weightAdjust = suggestion.details.popularity.relativePopularity;
+      }
     });
   };