views.py 文件源码

python
阅读 29 收藏 0 点赞 0 评论 0

项目:golem 作者: prihoda 项目源码 文件源码
def log_tests(request):

    es = get_elastic()
    if not es:
        return HttpResponse('not able to connect to elasticsearch')

    res = es.search(index="message-log", doc_type='message', body={
    "size": 0,
    "aggs" : {
        "test_ids" : {
            "terms" : { "field" : "test_id",  "size" : 500 }
        }
    }})
    test_ids = []
    for bucket in res['aggregations']['test_ids']['buckets']:
        test_id = bucket['key']
        test_ids.append({'id':'test_id_'+test_id, 'name':test_id})


    context = {
        'groups' : test_ids
    }
    template = loader.get_template('golem/log.html')
    return HttpResponse(template.render(context,request))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号