Przeglądaj źródła

[search] Adding 0 for null or empty hit widgets

Romain Rigaux 10 lat temu
rodzic
commit
f4c3ba9

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

@@ -104,9 +104,9 @@ def _guess_range_facet(widget_type, solr_api, collection, facet_field, propertie
       if difference < 2:
         gap = '+1SECONDS'
       elif difference < 5:
-        gap = '+5SECONDS'        
+        gap = '+5SECONDS'
       elif difference < 30:
-        gap = '+30SECONDS' 
+        gap = '+30SECONDS'
       elif difference < 100:
         gap = '+1MINUTES'
       elif difference < 60 * 5:

+ 6 - 6
apps/search/src/search/templates/search.mako

@@ -79,7 +79,7 @@ ${ commonheader(_('Search'), "search", user, "80px") | n,unicode }
         <input type="checkbox" data-bind="checked: showCores" />${ _('Show cores') }
         <i class="fa fa-spinner fa-spin" data-bind="visible: isSyncingCollections"></i>
       </label>
-      
+
       <span data-bind="template: {name: 'time-filter'}"></span>
     <!-- /ko -->
   </form>
@@ -133,9 +133,9 @@ ${ commonheader(_('Search'), "search", user, "80px") | n,unicode }
         <option value="1YEARS">${ _('Past Year') }</option>
         <option value="2YEARS">${ _('Past 2 Years') }</option>
         <option value="10YEARS">${ _('Past 10 Years') }</option>
-      </select>      
+      </select>
     </span>
-    
+
     <span data-bind="visible: collection.timeFilter.type() == 'fixed'">
       Start date/time <input type="text" data-bind="collection.timeFilter.from"></input>
       End date/time <input type="text" data-bind="collection.timeFilter.to"></input>
@@ -144,8 +144,8 @@ ${ commonheader(_('Search'), "search", user, "80px") | n,unicode }
     <button class="btn">
       <i class="fa fa-calendar"></i>
     </button>
-    
-    <span>  
+
+    <span>
       <a data-bind="style: { fontWeight: collection.timeFilter.type() == 'rolling' ? 'bold' : '' }, click: function() {collection.timeFilter.type('rolling'); }">Rolling</a> |
       <a data-bind="style: { fontWeight: collection.timeFilter.type() == 'fixed' ? 'bold' : '' }, click: function() {collection.timeFilter.type('fixed'); }">Fixed</a>
     </span>
@@ -855,7 +855,7 @@ ${ dashboard.layout_skeleton() }
   <div class="row-fluid" data-bind="with: $root.getFacetFromQuery(id())">
     <div data-bind="visible: $root.isEditing, with: $root.collection.getFacetById($parent.id())" style="margin-bottom: 20px">
       <span data-bind="template: { name: 'facet-toggle' }">
-      </span>      
+      </span>
     </div>
 
     <div style="padding-bottom: 10px; text-align: right; padding-right: 20px" data-bind="visible: counts().length > 0">

+ 5 - 4
desktop/libs/libsolr/src/libsolr/api.py

@@ -129,7 +129,7 @@ class SolrApi(object):
     }
 
     time_field = collection['timeFilter'].get('field')
-    
+
     if time_field and collection['timeFilter']['value'] != 'all':
       # fqs overrides main time filter
       fq_time_ids = [fq['id'] for fq in query['fqs'] if fq['field'] == time_field]
@@ -145,7 +145,7 @@ class SolrApi(object):
         props['field'] = collection['timeFilter']['field']
         props['from'] = collection['timeFilter']['from']
         props['to'] = collection['timeFilter']['to']
-            
+
     return props
 
   def _get_fq(self, collection, query):
@@ -153,7 +153,7 @@ class SolrApi(object):
 
     timeFilter = self._get_range_borders(collection, query)
     if timeFilter and not timeFilter.get('time_filter_overrides'):
-      params += (('fq', urllib.unquote(utf_quoter('%(field)s:[%(from)s TO %(to)s}' % timeFilter))),)
+      params += (('fq', urllib.unquote(utf_quoter('%(field)s:[%(from)s TO %(to)s]' % timeFilter))),)
 
     # Merge facets queries on same fields
     grouped_fqs = groupby(query['fqs'], lambda x: (x['type'], x['field']))
@@ -232,7 +232,7 @@ class SolrApi(object):
               'key': '%(field)s-%(id)s' % facet,
               'start': facet['properties']['start'],
               'end': facet['properties']['end'],
-              'gap': facet['properties']['gap'],              
+              'gap': facet['properties']['gap'],
               'mincount': int(facet['properties']['mincount'])
           }
 
@@ -299,6 +299,7 @@ class SolrApi(object):
           json_facets[facet['id']] = _f
         elif facet['type'] == 'function':
           json_facets[facet['id']] = self._get_aggregate_function(facet)
+          json_facets['processEmpty'] = True
         elif facet['type'] == 'pivot':
           if facet['properties']['facets'] or facet['widgetType'] == 'map-widget':
             fields = facet['field']