Эх сурвалжийг харах

HUE-3450 [metastore] Sort tables by popularity

Johan Ahlen 9 жил өмнө
parent
commit
f1638cd2fb

+ 12 - 0
apps/metastore/src/metastore/static/metastore/js/metastore.ko.js

@@ -65,6 +65,18 @@
         });
       }
       return returned.sort(function (a, b) {
+        if (typeof a.optimizerStats() !== 'undefined' && a.optimizerStats() !== null) {
+          if (typeof b.optimizerStats() !== 'undefined' && b.optimizerStats() !== null) {
+            if (a.optimizerStats().popularity === b.optimizerStats().popularity) {
+              return a.name.toLowerCase().localeCompare(b.name.toLowerCase());
+            }
+            return  b.optimizerStats().popularity - a.optimizerStats().popularity;
+          }
+          return -1
+        }
+        if (typeof b.optimizerStats() !== 'undefined' && b.optimizerStats() !== null) {
+          return 1;
+        }
         return a.name.toLowerCase().localeCompare(b.name.toLowerCase());
       });
     });