浏览代码

HUE-5116 [search] Get number of buckets in range facets

Romain Rigaux 9 年之前
父节点
当前提交
af1fb7e

+ 3 - 3
apps/search/src/search/models.py

@@ -838,7 +838,7 @@ def augment_solr_response(response, collection, query):
 
         # Number or Date range
         if collection_facet['properties']['canRange'] and not facet['properties'].get('type') == 'field':
-          dimension = 3
+          dimension = 3 if collection_facet['properties']['isDate'] else 1
           # Single dimension or dimension 2 with analytics
           if not collection_facet['properties']['facets'] or collection_facet['properties']['facets'][0]['aggregate']['function'] != 'count' and len(collection_facet['properties']['facets']) == 1:
             column = 'count'
@@ -856,7 +856,6 @@ def augment_solr_response(response, collection, query):
             counts = range_pair(facet['field'], name, selected_values.get(facet['id'], []), counts, 1, collection_facet)
           else:
             # Dimension 1 with counts and 2 with analytics
-
             agg_keys = [key for key, value in counts[0].items() if key.lower().startswith('agg_') or key.lower().startswith('dim_')]
             agg_keys.sort(key=lambda a: a[4:])
 
@@ -925,6 +924,7 @@ def augment_solr_response(response, collection, query):
 
           counts = filter(lambda a: len(a['fq_fields']) == actual_dimension, counts)
 
+        num_bucket = response['facets'][name]['numBuckets'] if 'numBuckets' in response['facets'][name] else len(response['facets'][name])
         facet = {
           'id': collection_facet['id'],
           'field': facet['field'],
@@ -933,7 +933,7 @@ def augment_solr_response(response, collection, query):
           'counts': counts,
           'extraSeries': extraSeries,
           'dimension': dimension,
-          'response': {'response': {'start': 0, 'numFound': response['facets'][name]['numBuckets']}}, # Todo * nested buckets + offsets
+          'response': {'response': {'start': 0, 'numFound': num_bucket}}, # Todo * nested buckets + offsets
           'docs': [dict(zip(cols, row)) for row in rows],
           'fieldsAttributes': [Collection2._make_gridlayout_header_field({'name': col, 'type': 'aggr' if '(' in col else 'string'}) for col in cols]
         }

+ 4 - 3
apps/search/src/search/templates/common_search.mako

@@ -15,9 +15,10 @@
 ## limitations under the License.
 
 <%!
-from desktop.views import commonheader, commonfooter, _ko
-from desktop import conf
 from django.utils.translation import ugettext as _
+
+from desktop import conf
+from desktop.views import commonheader, commonfooter, _ko
 %>
 
 <%namespace name="dashboard" file="common_dashboard.mako" />
@@ -3603,7 +3604,7 @@ $(document).ready(function () {
 });
 
 
-  function toggleGridFieldsSelection(widget) {console.log();
+  function toggleGridFieldsSelection(widget) {
     if (widget.widgetType() == 'resultset-widget') {
       viewModel.resultsHash = '';
     } else {

+ 1 - 1
desktop/core/src/desktop/templates/responsive.mako

@@ -170,7 +170,7 @@ ${ hueIcons.symbols() }
       </div>
     </div>
     <div class="top-nav-right">
-      % if user.is_authenticated() and section != 'login':        
+      % if user.is_authenticated() and section != 'login':
         <div class="compose-action btn-group">
           <%
             view_profile = user.has_hue_permission(action="access_view:useradmin:edit_user", app="useradmin") or user.is_superuser