Browse Source

HUE-3450 [metastore] Integrate with real topTables

Romain Rigaux 9 years ago
parent
commit
425b753

+ 6 - 0
apps/metastore/src/metastore/templates/metastore.mako

@@ -461,6 +461,7 @@ ${ assist.assistPanel() }
               </td>
               </td>
               <td data-bind="text: comment"></td>
               <td data-bind="text: comment"></td>
               <!-- ko if: $root.optimizerEnabled -->
               <!-- ko if: $root.optimizerEnabled -->
+                <!-- ko if: optimizerStats() -->
                 <td>
                 <td>
                   <div class="progress" style="height: 10px; width: 70px; margin-top:5px;">
                   <div class="progress" style="height: 10px; width: 70px; margin-top:5px;">
                     <div class="bar" style="background-color: #338bb8" data-bind="style: { 'width' : optimizerStats().popularity + '%' }, attr: {'title': optimizerStats().popularity} "></div>
                     <div class="bar" style="background-color: #338bb8" data-bind="style: { 'width' : optimizerStats().popularity + '%' }, attr: {'title': optimizerStats().popularity} "></div>
@@ -468,6 +469,11 @@ ${ assist.assistPanel() }
                 </td>
                 </td>
                 <td data-bind="text: optimizerStats().column_count"></td>
                 <td data-bind="text: optimizerStats().column_count"></td>
               <!-- /ko -->
               <!-- /ko -->
+              <!-- ko ifnot: optimizerStats() -->
+                <td></td>
+                <td></td>
+              <!-- /ko -->
+              <!-- /ko -->
 
 
               <td class="center">
               <td class="center">
                 <!-- ko if: type == 'Table' -->
                 <!-- ko if: type == 'Table' -->

+ 1 - 1
desktop/libs/metadata/src/metadata/conf.py

@@ -106,7 +106,7 @@ OPTIMIZER = ConfigSection(
     MOCKING = Config(
     MOCKING = Config(
       key="mocking",
       key="mocking",
       help=_t("Use mock data"),
       help=_t("Use mock data"),
-      default=True,
+      default=False,
       type=coerce_bool
       type=coerce_bool
     )
     )
   )
   )

+ 14 - 2
desktop/libs/metadata/src/metadata/optimizer_api.py

@@ -64,14 +64,26 @@ def top_tables(request):
   if OPTIMIZER.MOCKING.get():
   if OPTIMIZER.MOCKING.get():
     from beeswax.server import dbms
     from beeswax.server import dbms
     from beeswax.server.dbms import get_query_server_config
     from beeswax.server.dbms import get_query_server_config
-    
     db = dbms.get(request.user)
     db = dbms.get(request.user)
     tables = [
     tables = [
       {'name': table, 'popularity': random.randint(1, 100) , 'column_count': random.randint(1, 100), 'is_fact': bool(random.getrandbits(1))}
       {'name': table, 'popularity': random.randint(1, 100) , 'column_count': random.randint(1, 100), 'is_fact': bool(random.getrandbits(1))}
       for table in db.get_tables(database=database)
       for table in db.get_tables(database=database)
     ][:len]
     ][:len]
   else:
   else:
-    tables = api.top_tables()
+    """
+    Get back:
+    # u'details': [{u'columnCount': 28, u'name': u'date_dim', u'patternCount': 136, u'workloadPercent': 89, u'total': 92, u'type': u'Dimension', u'eid': u'19'},
+    """    
+    tables = [{
+        'id': table['eid'],
+        'name': table['name'],
+        'popularity': table['workloadPercent'],
+        'column_count': table['columnCount'],
+        'patternCount': table['patternCount'],
+        'total': table['total'],
+        'is_fact': table['type'] != 'Dimension'
+        } for table in api.top_tables()['details']
+    ]
 
 
   response['top_tables'] = tables
   response['top_tables'] = tables
   response['status'] = 0
   response['status'] = 0