def histo(request): client = CbClient() test_id = request.POST.get('id', uuid4().hex) description = request.POST.get('description', uuid4().hex) attachment = request.POST.get('attachment', '') attachment = json.loads(str(attachment)) histograms = client.find(test_id).get('histograms', {}) histograms.update({description: attachment}) doc = {'histograms': histograms} client.update(test_id, doc) return Response(test_id)
def report(request): client = CbClient() test_id = request.POST.get('test_id', uuid4().hex) description = request.POST.get('description', uuid4().hex) url = request.POST.get('url', '') reports = client.find(test_id).get('reports', {}) reports.update({description: url}) doc = {'reports': reports} client.update(test_id, doc) if request.POST.get('submit'): location = '/details?id={0}'.format(test_id) return HTTPFound(location) else: return Response(test_id)
def update(request): client = CbClient() test_id = request.POST.get('id', uuid4().hex) build = request.POST.get('build', '') spec = request.POST.get('spec', '') description = request.POST.get('description', '') timestamp = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) phase = request.POST.get('phase', '') status = request.POST.get('status', '') events = client.find(test_id).get('events', {}) events.update({timestamp: {'phase': phase, 'status': status}}) doc = {'build': build, 'spec': spec, 'description': description, 'events': events, 'type': 'update'} client.update(test_id, doc) return Response(test_id)