ソースを参照

HUE-3228 [dashboard] Support adding old timeline in current mode

Romain Rigaux 8 年 前
コミット
882f50b

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

@@ -225,7 +225,7 @@ def get_stats(request):
     field = analysis['name']
     facet = analysis['stats']['facet']
 
-    result['stats'] = SolrApi(SOLR_URL.get(), request.user).stats(collection['name'], [field], query, facet)
+    result['stats'] = get_engine(request.user, collection).stats(collection['name'], [field], query, facet)
     result['status'] = 0
     result['message'] = ''
 
@@ -393,10 +393,12 @@ def _create_facet(collection, user, facet_id, facet_label, facet_field, widget_t
     if widget_type in ('bucket-widget', 'pie2-widget', 'timeline-widget', 'tree2-widget', 'text-facet-widget', 'hit-widget'):
       if widget_type == 'text-facet-widget':
         properties['type'] = facet_type
+
       if widget_type == 'hit-widget':
         facet_type = 'function'
       else:
         facet_type = 'nested'
+
       properties['facets_form'] = {'field': '', 'mincount': 1, 'limit': 10, 'aggregate': {'function': 'unique', 'ops': [], 'percentiles': [{'value': 50}]}}
       properties['facets'] = []
       properties['domain'] = {'blockParent': [], 'blockChildren': []}
@@ -424,6 +426,11 @@ def _create_facet(collection, user, facet_id, facet_label, facet_field, widget_t
     else:
       properties['scope'] = 'stack' if widget_type == 'heatmap-widget' else 'tree'
 
+  if widget_type == 'histogram-widget':
+    properties['enableSelection'] = True
+    properties['timelineChartType'] = 'bar'
+    properties['extraSeries'] = []
+
   return {
     'id': facet_id,
     'label': facet_label,

+ 5 - 4
apps/search/src/search/api_engines.py

@@ -59,7 +59,7 @@ class DashboardApi(object):
 
   def update(self, collection, json_edits, content_type, version): pass
 
-  def stats(self, collection, field, query, facet): pass
+  def stats(self, collection, field, query=None, facet=''): pass
 
   def terms(self, collection, field, properties): pass
 
@@ -75,7 +75,7 @@ class SearchApi(DashboardApi):
   def query(self, collection, query, facet=None):
     response = self.api.query(collection, query)
     return augment_solr_response(response, collection, query)
-  
+
   def datasets(self, show_all=False):
     return SearchController(self.user).get_all_indexes(show_all=show_all)
 
@@ -84,8 +84,9 @@ class SearchApi(DashboardApi):
 
   def schema_fields(self, collection):
     return self.api.fields(collection)
-  
+
   def luke(self, collection):
     return self.api.luke(collection)
 
-  
+  def stats(self, collection, field, query=None, facet=''):
+    return self.api.stats(collection, field, query, facet)

+ 2 - 1
apps/search/src/search/facet_builder.py

@@ -27,6 +27,7 @@ from time import mktime
 
 from django.utils.translation import ugettext as _
 
+
 LOG = logging.getLogger(__name__)
 
 
@@ -44,7 +45,7 @@ def _guess_range_facet(widget_type, solr_api, collection, facet_field, propertie
     print e
     # stats not supported on all the fields, like text
     pass
-  
+
 def _compute_range_facet(widget_type, stat_facet, properties, start=None, end=None, gap=None):
 
     if widget_type == 'pie-widget' or widget_type == 'pie2-widget':

+ 3 - 1
apps/search/src/search/static/search/js/search.ko.js

@@ -669,7 +669,9 @@ var Collection = function (vm, collection) {
         return _fields;
       });
 
-      facet.properties.facets_form.aggregate.percentiles = ko.mapping.fromJS([{'value': 50}]);
+      if (typeof facets_form != 'undefined' && typeof facets_form.aggregate != 'undefined') {
+        facet.properties.facets_form.aggregate.percentiles = ko.mapping.fromJS([{'value': 50}]);
+      }
 
       facet.template.fieldsSelected.subscribe(function(newValue) { // Could be more efficient as we don't need to research, just redraw
         vm.getFacetFromQuery(facet.id()).resultHash('');