Browse Source

[search] Make sure min or max properties of range facet are restricted

Romain Rigaux 11 năm trước cách đây
mục cha
commit
354f17ec2b
2 tập tin đã thay đổi với 4 bổ sung2 xóa
  1. 3 1
      apps/search/src/search/api.py
  2. 1 1
      apps/search/src/search/views.py

+ 3 - 1
apps/search/src/search/api.py

@@ -93,6 +93,7 @@ def _guess_range_facet(widget_type, solr_api, collection, facet_field, propertie
         start_ts = datetime.strptime('1970-01-01T00:00:00Z', '%Y-%m-%dT%H:%M:%SZ')        
       start_ts, _ = _round_date_range(start_ts)
       start = start_ts.strftime('%Y-%m-%dT%H:%M:%SZ')
+      stats_min = min(stats_min, start)
       if end is None:
         end = stats_max
       end = re.sub('\.\d\d?\d?Z$', 'Z', end)
@@ -103,6 +104,7 @@ def _guess_range_facet(widget_type, solr_api, collection, facet_field, propertie
         end_ts = datetime.strptime('2050-01-01T00:00:00Z', '%Y-%m-%dT%H:%M:%SZ')
       _, end_ts = _round_date_range(end_ts)
       end = end_ts.strftime('%Y-%m-%dT%H:%M:%SZ')
+      stats_max = max(stats_max, end)
       difference = (
           mktime(end_ts.timetuple()) - 
           mktime(start_ts.timetuple())
@@ -128,7 +130,7 @@ def _guess_range_facet(widget_type, solr_api, collection, facet_field, propertie
         gap = '+1DAYS'
       elif difference < 3600 * 24 * 7:
         gap = '+7DAYS'        
-      elif difference < 3600 * 24 * 30:
+      elif difference < 3600 * 24 * 40:
         gap = '+1MONTHS'        
       else:
         gap = '+1YEARS'      

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

@@ -474,7 +474,7 @@ def install_examples(request):
   else:
     try:
       search_setup.Command().handle_noargs()
-      #indexer_setup.Command().handle_noargs()
+      indexer_setup.Command().handle_noargs()
       result['status'] = 0
     except Exception, e:
       LOG.exception(e)