Exemple #1
0
 def _get_time_filter_query(self, timeFilter, facet):
     if 'fixed' in timeFilter:
         props = {}
         stat_facet = {'min': timeFilter['from'], 'max': timeFilter['to']}
         _compute_range_facet(facet['widgetType'], stat_facet, props,
                              stat_facet['min'], stat_facet['max'])
         gap = props['gap']
         unit = re.split('\d+', gap)[1]
         return {
             'start': '%(from)s/%(unit)s' % {
                 'from': timeFilter['from'],
                 'unit': unit
             },
             'end': '%(to)s/%(unit)s' % {
                 'to': timeFilter['to'],
                 'unit': unit
             },
             'gap': '%(gap)s' % props,  # add a 'auto'
         }
     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'
         }
Exemple #2
0
 def _get_time_filter_query(self, timeFilter, facet, collection):
   properties = facet.get('properties', facet)
   if timeFilter:
     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 properties['start'] == properties['min'] and properties['end'] == properties['max']:
       stat_facet = {'min': timeFilter['from'], 'max': timeFilter['to']}
       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']
     return {
       'min': '%(min)s' % props,
       'max': '%(max)s' % props,
       'start': '%(start)s' % props,
       'end': '%(end)s' % props,
       'gap': '%(gap)s' % props,
     }
   else:
     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 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']]
       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'])
     return {
       'start': '%(start)s' % props,
       'end': '%(end)s' % props,
       'gap': '%(gap)s' % props,
       'min': '%(min)s' % props,
       'max': '%(max)s' % props,
     }