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

HUE-8178 [charts] Fix time intervals that have non standard durations

jdesjean преди 7 години
родител
ревизия
6c9b20a235
променени са 2 файла, в които са добавени 10 реда и са изтрити 5 реда
  1. 2 1
      desktop/libs/dashboard/src/dashboard/facet_builder.py
  2. 8 4
      desktop/libs/libsolr/src/libsolr/api.py

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

@@ -25,6 +25,7 @@ from datetime import datetime, timedelta
 from math import ceil
 from math import log
 from time import mktime
+from dateutil.relativedelta import *
 
 from django.utils.translation import ugettext as _
 
@@ -142,7 +143,7 @@ def _get_next_interval(interval, start_time, do_at_least_once):
   time = start_time
   while getattr(time, gap_duration_lowers) % gap_duration or (do_at_least_once and time == start_time): # Do while
     kwargs = {gap_duration_lower: 1}
-    time = time + timedelta(milliseconds=interval['base_ms'])
+    time = time + relativedelta(time, **kwargs)
   return time
 
 def _compute_range_facet(widget_type, stat_facet, properties, start=None, end=None, gap=None, SLOTS=0, window_size=None):

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

@@ -254,8 +254,8 @@ class SolrApi(object):
       ('hl.fragsize', 1000),
     )
 
-    if query.get('timezone'):
-      params += (('TZ', query.get('timezone')),)
+    #if query.get('timezone'):
+    #  params += (('TZ', query.get('timezone')),)
 
     if collection['template']['fieldsSelected']:
       fields = []
@@ -951,12 +951,14 @@ class SolrApi(object):
         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']
+      unit = re.split('\d+', gap)[1]
       return {
         'min': '%(min)s' % props,
         'max': '%(max)s' % props,
         'start': '%(start)s' % props,
         'end': '%(end)s' % props,
-        'gap': '%(gap)s' % props,  # add a 'auto'
+        'gap': '%(gap)s/%(unit)s' % {'gap': gap, 'unit': unit},
       }
     elif timeFilter:
       props = {}
@@ -970,10 +972,12 @@ class SolrApi(object):
       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']
+      unit = re.split('\d+', gap)[1]
       return {
         'start': '%(start)s' % props,
         'end': '%(end)s' % props,
-        'gap': '%(gap)s' % props,  # add a 'auto'
+        'gap': '%(gap)s/%(unit)s' % {'gap': gap, 'unit': unit},
         'min': '%(min)s' % props,
         'max': '%(max)s' % props,
       }