Ver Fonte

HUE-3294 [search] Do not show input function for non function like field

Romain Rigaux há 9 anos atrás
pai
commit
fd76a88

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

@@ -827,7 +827,7 @@ def augment_solr_response(response, collection, query):
         if collection_facet['properties']['canRange'] and not facet['properties'].get('type') == 'field':
           dimension = 3
           # Single dimension or dimension 2 with analytics
-          if not collection_facet['properties']['facets'] or collection_facet['properties']['facets'][0]['aggregate'] not in ('count', 'unique'):
+          if not collection_facet['properties']['facets'] or collection_facet['properties']['facets'][0]['aggregate']['function'] not in ('count', 'unique'):
             counts = [_v for _f in counts for _v in (_f['val'], _f['d2'] if 'd2' in _f else _f['count'])]
             counts = range_pair(facet['field'], name, selected_values.get(facet['id'], []), counts, 1, collection_facet)
           else:
@@ -842,11 +842,11 @@ def augment_solr_response(response, collection, query):
               extraSeries.append({'counts': _c, 'label': name})
             counts = []
         elif collection_facet['properties'].get('isOldPivot'):
-          facet_fields = [collection_facet['field']] + [f['field'] for f in collection_facet['properties'].get('facets', []) if f['aggregate'] == 'count']
+          facet_fields = [collection_facet['field']] + [f['field'] for f in collection_facet['properties'].get('facets', []) if f['aggregate']['function'] == 'count']
           count = response['facets'][name]
           _convert_nested_to_augmented_pivot_nd(facet_fields, facet['id'], count, selected_values, dimension=2)
           dimension = len(facet_fields)
-        elif not collection_facet['properties']['facets'] or collection_facet['properties']['facets'][0]['aggregate'] not in ('count', 'unique'):
+        elif not collection_facet['properties']['facets'] or collection_facet['properties']['facets'][0]['aggregate']['function'] not in ('count', 'unique'):
           # Single dimension or dimension 2 with analytics
           dimension = 1
           counts = [_v for _f in counts for _v in (_f['val'], _f['d2'] if 'd2' in _f else _f['count'])]

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

@@ -1987,9 +1987,9 @@ ${ dashboard.layout_skeleton() }
 
 <script type="text/html" id="metric-form">
   <div data-bind="visible: $root.isEditing" style="margin-bottom: 20px">    
-    ##<!-- ko if: ['sum', 'avg', 'unique', 'percentile', 'mul', 'add', 'sub', 'ms'].indexOf($data.function()) != -1 -->
+    <!-- ko if: $data.function() != 'field' -->
       <select data-bind="options: HIT_OPTIONS, optionsText: 'label', optionsValue: 'value', value: $data.function" class="input-medium"></select>
-    ##<!-- /ko -->
+    <!-- /ko -->
     
     <!-- ko if: $data.function() == 'field' -->
       <select data-bind="selectize: $root.collection.template.fieldsNames, options: $root.collection.template.fieldsNames, value: value, selectizeOptions: {create: true}, optionsCaption: '${ _ko('Field...') }'" class="hit-options" style="margin-bottom: 0"></select>
@@ -2015,7 +2015,7 @@ ${ dashboard.layout_skeleton() }
 
     <br/>
     <a href="javascript: void(0)" data-bind="click: function() {
-        $data.ops.push(ko.mapping.fromJS({'function': 'mul', 'ops': [{'function': 'field', 'value': '', 'ops': []}, {'function': 'field', 'value': '1', 'ops': []}]})); }
+        ops.push(ko.mapping.fromJS({'function': 'mul', 'ops': [{'function': 'field', 'value': '', 'ops': []}, {'function': 'field', 'value': '1', 'ops': []}]})); }
       ">
       <i class="fa fa-plus" title="${ _('Add formula operation') }"></i>
     </a>

+ 1 - 1
desktop/libs/libsolr/src/libsolr/api.py

@@ -249,7 +249,7 @@ class SolrApi(object):
   def _n_facet_dimension(self, widget, _f, facets, dim):
     facet = facets[0]
     f_name = 'd%s' % dim
-    print facets
+
     if facet['aggregate']['function'] == 'count':
       _f['facet'] = {
           f_name: {