def submit_view(request): api_key = request.GET.get('key', None) heka_client = get_heka_client() if api_key is None: # we don't require API keys for submit yet heka_client.incr('submit.no_api_key') else: heka_client.incr('submit.api_key.%s' % api_key.replace('.', '__')) data, errors = preprocess_request( request, schema=SubmitSchema(), extra_checks=(submit_validator, ), ) items = data['items'] nickname = request.headers.get('X-Nickname', u'') if isinstance(nickname, str): nickname = nickname.decode('utf-8', 'ignore') # batch incoming data into multiple tasks, in case someone # manages to submit us a huge single request for i in range(0, len(items), 100): insert_measures.delay( # TODO convert items to json with support for decimal/datetime items=dumps(items[i:i + 100]), nickname=nickname, ) return HTTPNoContent()
def submit_view(request): data, errors = preprocess_request( request, schema=SubmitSchema(), extra_checks=(submit_validator, ), ) items = data['items'] nickname = request.headers.get('X-Nickname', u'') if isinstance(nickname, str): nickname = nickname.decode('utf-8', 'ignore') # batch incoming data into multiple tasks, in case someone # manages to submit us a huge single request for i in range(0, len(items), 100): insert_measures.delay( items=dumps(items[i:i + 100]), nickname=nickname, ) return HTTPNoContent()
def submit_view(request): data, errors = preprocess_request( request, schema=SubmitSchema(), extra_checks=(submit_validator, ), ) items = data['items'] nickname = request.headers.get('X-Nickname', u'') if isinstance(nickname, str): nickname = nickname.decode('utf-8', 'ignore') # batch incoming data into multiple tasks, in case someone # manages to submit us a huge single request for i in range(0, len(items), 100): insert_measures.delay( # TODO convert items to json with support for decimal/datetime items=dumps(items[i:i + 100]), nickname=nickname, ) return HTTPNoContent()