Example #1
0
    def send_annotations(self):
        request = self.request
        user = get_user(request)
        annotations = Annotation.search_raw(query=self.query.query, user=user)
        self.received = len(annotations)

        packet = _annotation_packet(annotations, 'past')
        data = json.dumps(packet)
        self.send(data)
Example #2
0
def _search(request_params, user=None):
    # Compile search parameters
    search_params = _search_params(request_params, user=user)

    log.debug("Searching with user=%s, for uri=%s",
              user.id if user else 'None', request_params.get('uri'))

    if 'any' in search_params['query']:
        # Handle any field parameters
        query = _add_any_field_params_into_query(search_params)
        results = Annotation.search_raw(query)

        params = {'search_type': 'count'}
        count = Annotation.search_raw(query, params, raw_result=True)
        total = count['hits']['total']
    else:
        results = Annotation.search(**search_params)
        total = Annotation.count(**search_params)

    return {
        'rows': results,
        'total': total,
    }
Example #3
0
    def send_annotations(self):
        request = self.request
        user = get_user(request)
        annotations = Annotation.search_raw(query=self.query.query, user=user)
        self.received = len(annotations)

        # Can send zero to indicate that no past data is matched
        packet = {
            'payload': annotations,
            'type': 'annotation-notification',
            'options': {
                'action': 'past',
            }
        }
        self.send(packet)