def send_backfill_request(self,
                              query_syntax,
                              feeds,
                              name,
                              query=None,
                              request_from=None,
                              request_to=None):
        payload = {'use_query_syntax': False, 'backfill_name': name}
        if query_syntax:
            assert query is not None
            payload['use_query_syntax'] = True
            payload['query'] = query
        else:
            assert request_from is not None
            assert request_to is not None
            payload['from'] = request_from
            payload['to'] = request_to

        for feed_group in iter_list_chunks(
                feeds, ManagedFeedsManager.FEED_GROUP_SIZE):
            payload['points'] = feed_group

            msg_id = self.sqs_service.send_structured_message(
                payload=payload, action='backfill')

            self.managed_feeds_dao.create_backfill_event(
                id=msg_id,
                pi_points=feed_group,
                name=name if name is not None else 'Backfill')
    def send_interpolate_request(self,
                                 query_syntax,
                                 feeds,
                                 interval,
                                 interval_unit,
                                 name,
                                 query=None,
                                 request_from=None,
                                 request_to=None):
        interval_seconds = self._interval_seconds(interval, interval_unit)
        payload = {
            'use_date_query_syntax': False,
            'interval_seconds': interval_seconds,
            'interpolation_name': name
        }
        if query_syntax:
            payload['use_date_query_syntax'] = True
            payload['date_query'] = query
        else:
            payload['from'] = request_from
            payload['to'] = request_to

        for feed_group in iter_list_chunks(
                feeds, ManagedFeedsManager.FEED_GROUP_SIZE):
            payload['points'] = feed_group
            msg_id = self.sqs_service.send_structured_message(
                action='interpolate', payload=payload)
            self.managed_feeds_dao.create_interpolation_event(
                pi_points=feed_group,
                id=msg_id,
                name=name if name is not None else 'Interpolate')
Exemple #3
0
 def send_unsubscribe_request(self, pi_points):
     for feed_group in iter_list_chunks(pi_points, ManagedFeedsManager.FEED_GROUP_SIZE):
         msg_id = self.sqs_service.send_structured_message(
             payload={"points": feed_group},
             action='unsubscribe'
         )
         self.managed_feeds_dao.create_event(msg_id, feed_group, 'unsubscribe')
         self.managed_feeds_dao.update_pi_points_status(feed_group, 'pending')