Ejemplo n.º 1
0
 def _parse_data_point_as_sources(self, data_point):
     Logger.Info('%s - SearchDataPointParser._parse_data_point - started' % __name__)
     dpc = DataPointController(data_point)
     data_point_query = 'source_id:%s' % dpc.generate_configured_guid()
     Logger.Info('%s - SearchDataPointParser._parse_data_point - finished' % __name__)
     return data_point_query
 def AggregateMultipleDataPointHistoryWithAction(cls, action, data_points, historic_limit):
     Logger.Info('%s - AggregationController.AggregateMultipleDataPointHistoryWithAction - started' % __name__)
     Logger.Debug('%s - AggregationController.AggregateMultipleDataPointHistoryWithAction - started with action:%s and data_point:%s and historic_limit:%s' % (__name__, action, data_points, historic_limit))
     for data_point in data_points:
         dpc = DataPointController(data_point)
         solr_url = settings.SOLR_CONFIG['solr_url']
         solr_url = '%s/select/?q=*:*&wt=json&sort=time+desc&rows=%i&fq=source_id:%s' % (solr_url, historic_limit, dpc.generate_configured_guid())
         try:
             request = urllib2.Request(solr_url)
             response = urllib2.urlopen(request)
             response = json.loads(response.read())
         except Exception, e:
             Logger.Error('%s - AggregationController.AggregateMultipleDataPointHistoryWithAction - error:%s' % (__name__, e))
             Logger.Info('%s - AggregationController.AggregateMultipleDataPointHistoryWithAction - finished' % __name__)
             return
         content_from_solr = response['response']['docs']
         content_with_action_applied = apply_actions_to_content_with_historical_check(content_from_solr, [action])
         post_content_to_solr(content_with_action_applied)