瀏覽代碼

HUE-8456 [search] Fix web_logs & yelp demo.

jdesjean 7 年之前
父節點
當前提交
0e37d6e

+ 4 - 4
apps/search/src/search/tests.py

@@ -37,11 +37,11 @@ QUERY = {'qs': [{'q': ''}], 'fqs': [], 'start': 0}
 
 
 def test_ranges():
-  assert_equal((90.0, 100.0), _round_number_range(99))
-  assert_equal((0.0, 100.0), _round_number_range(100))
-  assert_equal((0.0, 100.0), _round_number_range(101))
+  assert_equal((90, 100), _round_number_range(99))
+  assert_equal((0, 100), _round_number_range(100))
+  assert_equal((0, 100), _round_number_range(101))
 
-  assert_equal((8000000.0, 9000000.0), _round_number_range(9045352))
+  assert_equal((8000000, 9000000), _round_number_range(9045352))
 
 
 class MockResource():

+ 1 - 1
desktop/libs/dashboard/src/dashboard/facet_builder.py

@@ -278,7 +278,7 @@ def _round_number_range(n):
     return n, n + 1
   else:
     i = int(log(n, 10))
-    end = round(n, -i)
+    end = int(round(n, -i))
     start = end - 10 ** i
     return start, end
 

+ 4 - 4
desktop/libs/dashboard/src/dashboard/tests.py

@@ -37,11 +37,11 @@ QUERY = {'qs': [{'q': ''}], 'fqs': [], 'start': 0}
 
 
 def test_ranges():
-  assert_equal((90.0, 100.0), _round_number_range(99))
-  assert_equal((0.0, 100.0), _round_number_range(100))
-  assert_equal((0.0, 100.0), _round_number_range(101))
+  assert_equal((90, 100), _round_number_range(99))
+  assert_equal((0, 100), _round_number_range(100))
+  assert_equal((0, 100), _round_number_range(101))
 
-  assert_equal((8000000.0, 9000000.0), _round_number_range(9045352))
+  assert_equal((8000000, 9000000), _round_number_range(9045352))
 
 
 class MockResource():

+ 10 - 25
desktop/libs/libsolr/src/libsolr/api.py

@@ -939,12 +939,12 @@ class SolrApi(object):
 
   def _get_time_filter_query(self, timeFilter, facet, collection):
     properties = facet.get('properties', facet)
-    if not timeFilter and properties['slot'] != 0:
+    if timeFilter:
       props = {}
-      # If the start & end are equal to min/max, then we want to show the whole domain. Since min/max can change, we fetch latest values and update start/end
+      # If the start & end are equal to min/max, then we want to show the whole domain (either interval now-x or static)
+      # In that case use timeFilter values
       if properties['start'] == properties['min'] and properties['end'] == properties['max']:
-        stats_json = self.stats(collection['name'], [facet['field']])
-        stat_facet = stats_json['stats']['stats_fields'][facet['field']]
+        stat_facet = {'min': timeFilter['from'], 'max': timeFilter['to']}
         properties['start'] = None
         properties['end'] = None
       else: # The user has zoomed in. Only show that section.
@@ -952,46 +952,31 @@ class SolrApi(object):
       _compute_range_facet(facet['widgetType'], stat_facet, props, properties['start'], properties['end'],
                            SLOTS=properties['slot'])
       gap = props['gap']
-      if isinstance(gap, basestring):
-        unit = re.split('\d+', gap)[1]
-      else:
-        unit = ''
       return {
         'min': '%(min)s' % props,
         'max': '%(max)s' % props,
         'start': '%(start)s' % props,
         'end': '%(end)s' % props,
-        'gap': '%(gap)s/%(unit)s' % {'gap': gap, 'unit': unit} if unit else '%(gap)s' % {'gap': gap},
+        'gap': '%(gap)s' % props,
       }
-    elif timeFilter:
+    else:
       props = {}
-
-      # If the start & end are equal to min/max, then we want to show the whole domain (either interval now-x or static)
-      # In that case use timeFilter values
+      # If the start & end are equal to min/max, then we want to show the whole domain. Since min/max can change, we fetch latest values and update start/end
       if properties['start'] == properties['min'] and properties['end'] == properties['max']:
-        stat_facet = {'min': timeFilter['from'], 'max': timeFilter['to']}
+        stats_json = self.stats(collection['name'], [facet['field']])
+        stat_facet = stats_json['stats']['stats_fields'][facet['field']]
         properties['start'] = None
         properties['end'] = None
       else: # the user has zoomed in. Only show that section.
         stat_facet = {'min': properties['min'], 'max': properties['max']}
       _compute_range_facet(facet['widgetType'], stat_facet, props, properties['start'], properties['end'], SLOTS = properties['slot'])
-      gap = props['gap']
-      if isinstance(gap, basestring):
-        unit = re.split('\d+', gap)[1]
       return {
         'start': '%(start)s' % props,
         'end': '%(end)s' % props,
-        'gap': '%(gap)s/%(unit)s' % {'gap': gap, 'unit': unit} if unit else '%(gap)s' % {'gap': gap},
+        'gap': '%(gap)s' % props,
         'min': '%(min)s' % props,
         'max': '%(max)s' % props,
       }
-    else:
-      gap = timeFilter['gap'][facet['widgetType']]
-      return {
-        'start': '%(from)s/%(unit)s' % {'from': timeFilter['from'], 'unit': gap['unit']},
-        'end': '%(to)s/%(unit)s' % {'to': timeFilter['to'], 'unit': gap['unit']},
-        'gap': '%(coeff)s%(unit)s/%(unit)s' % gap, # add a 'auto'
-      }
 
   def _get_fq(self, collection, query):
     params = ()