Преглед на файлове

[search] Fix pivot facet counts

Romain Rigaux преди 11 години
родител
ревизия
093465a
променени са 3 файла, в които са добавени 12 реда и са изтрити 16 реда
  1. 8 8
      apps/search/src/search/models.py
  2. 3 7
      apps/search/src/search/templates/search.mako
  3. 1 1
      apps/search/src/search/views.py

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

@@ -536,28 +536,28 @@ def augment_solr_response(response, collection, query):
 
 def _augment_pivot_2d(counts):
   values = set()
-  
+
   for dimension in counts:
     for pivot in dimension['pivot']:
       values.add(pivot['value'])
-  
+
   values = sorted(list(values))
-  
+
   augmented = []
-  
+
   for dimension in counts:
     count = {}
     for pivot in dimension['pivot']:
       count[pivot['value']] = pivot['count']
     for val in values:
-      if val in count:      
-        c = {"count": count[pivot['value']], "value": val, "cat": dimension['value']}
+      if val in count:
+        c = {"count": count[val], "value": val, "cat": dimension['value']}
       else:
         c = {"count": 0, "value": val, "cat": dimension['value']}
       augmented.append(c)
-      
+
   return augmented
-    
+
 
 def augment_solr_exception(response, collection):
   response.update(

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

@@ -262,8 +262,8 @@ ${ dashboard.layout_skeleton() }
             ${ _('Plot') }
           </span>
           <select data-bind="selectedOptions: properties.scope" class="input-small">
-            <option value="tree">${ _("Tree") }</option>
             <option value="stack">${ _("Bars") }</option>
+            <option value="tree">${ _("Tree") }</option>
           </select>
         </span>
       </div>
@@ -299,7 +299,7 @@ ${ dashboard.layout_skeleton() }
               ${ _('Min Count') }
             </span>
             <input type="text" class="input-medium" data-bind="spinedit: properties.facets_form.mincount"/>
-            <a href="javascript: void(0)" data-bind="visible: ko.toJSON(properties.facets_form.field) != '', click: $root.collection.addPivotFacetValue">
+            <a class="pull-right" href="javascript: void(0)" data-bind="visible: ko.toJSON(properties.facets_form.field) != '', click: $root.collection.addPivotFacetValue">
               <i class="fa fa-plus"></i>
             </a>
           </span>
@@ -894,11 +894,7 @@ ${ dashboard.layout_skeleton() }
           onComplete: function(){ viewModel.getWidgetById(id()).isLoading(false) } }"
         />
       <!-- /ko -->
-
-      <!-- ko if: properties.scope() == 'heat' -->
-        <span data-bind="text: ko.mapping.toJSON($parent.count)"></span>
-      <!-- /ko -->
-    </div>    
+    </div>
   </div>
   <!-- /ko -->
 

+ 1 - 1
apps/search/src/search/views.py

@@ -474,7 +474,7 @@ def _create_facet(collection, user, facet_id, facet_label, facet_field, widget_t
     properties['mincount'] = 1
     properties['facets'] = []
     properties['facets_form'] = {'field': '', 'mincount': 1, 'limit': 5}
-    properties['scope'] = 'tree'
+    properties['scope'] = 'stack'
 
   return {
     'id': facet_id,