فهرست منبع

[search] Make corrrect the counts of an esc range facet

Fix the rounding of upper side too.
Romain Rigaux 10 سال پیش
والد
کامیت
423b76abd6
2فایلهای تغییر یافته به همراه3 افزوده شده و 3 حذف شده
  1. 2 2
      apps/search/src/search/models.py
  2. 1 1
      desktop/libs/libsolr/src/libsolr/api.py

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

@@ -468,13 +468,12 @@ def range_pair(field, cat, fq_filter, iterable, end, collection_facet):
   a, to = itertools.tee(iterable)
   next(to, None)
   counts = iterable[1::2]
-  total_counts = 0
+  total_counts = counts.pop(0) if collection_facet['properties']['sort'] == 'asc' else 0
 
   for element in a:
     next(to, None)
     to_value = next(to, end)
     count = next(a)
-    total_counts += counts.pop(0)
 
     pairs.append({
         'field': field, 'from': element, 'value': count, 'to': to_value, 'selected': element in selected_values,
@@ -483,6 +482,7 @@ def range_pair(field, cat, fq_filter, iterable, end, collection_facet):
         'total_counts': total_counts,
         'is_up': is_up
     })
+    total_counts += counts.pop(0) if counts else 0
 
   if collection_facet['properties']['sort'] == 'asc' and collection_facet['type'] != 'range-up':
     pairs.reverse()

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

@@ -101,7 +101,7 @@ class SolrApi(object):
                     utf_quoter('%s%s:[%s TO %s}' % ('-' if field['exclude'] else '', fq['field'], f['from'], f['to']))) for field, f in zip(fq['filter'], fq['properties'])])),)
       elif fq['type'] == 'range-up':
         params += (('fq', '{!tag=%s}' % fq['field'] + ' '.join([urllib.unquote(
-                    utf_quoter('%s%s:[%s TO %s]' % ('-' if field['exclude'] else '', fq['field'], f['from'] if fq['is_up'] else '*', '*' if fq['is_up'] else f['from'])))
+                    utf_quoter('%s%s:[%s TO %s}' % ('-' if field['exclude'] else '', fq['field'], f['from'] if fq['is_up'] else '*', '*' if fq['is_up'] else f['from'])))
                                                           for field, f in zip(fq['filter'], fq['properties'])])),)
     return params