예제 #1
0
def get_top10_count():

    try:
        query, _, _, group, _, _, _ = parse_fields(request.args)
    except Exception as e:
        return jsonify(status="error", message=str(e)), 400

    try:
        top10 = db.get_topn_count(query=query, group=group, limit=10)
    except Exception as e:
        return jsonify(status="error", message=str(e)), 500

    for item in top10:
        for resource in item['resources']:
            resource['href'] = absolute_url('/alert/' + resource['id'])

    if top10:
        return jsonify(status="ok", total=len(top10), top10=top10)
    else:
        return jsonify(
            status="ok",
            message="not found",
            total=0,
            top10=[],
        )
예제 #2
0
def get_top10_count():

    try:
        query, _, _, group, _, _, _ = parse_fields(request.args)
    except Exception as e:
        return jsonify(status="error", message=str(e)), 400

    try:
        top10 = db.get_topn_count(query=query, group=group, limit=10)
    except Exception as e:
        return jsonify(status="error", message=str(e)), 500

    for item in top10:
        for resource in item['resources']:
            resource['href'] = absolute_url('/alert/' + resource['id'])

    if top10:
        return jsonify(
            status="ok",
            total=len(top10),
            top10=top10
        )
    else:
        return jsonify(
            status="ok",
            message="not found",
            total=0,
            top10=[],
        )
예제 #3
0
 def get_top10_count(query: Query = None) -> List[Dict[str, Any]]:
     return db.get_topn_count(query, topn=10)
예제 #4
0
파일: alert.py 프로젝트: Toniob/alerta
 def get_top10_count(query=None):
     return db.get_topn_count(query, topn=10)
예제 #5
0
파일: alert.py 프로젝트: 3IWOH/alerta
 def get_top10_count(query=None):
     return db.get_topn_count(query)
예제 #6
0
파일: alert.py 프로젝트: simhaonline/alerta
 def get_topn_count(query: Query = None,
                    topn: int = 10) -> List[Dict[str, Any]]:
     return db.get_topn_count(query, topn=topn)
예제 #7
0
파일: alert.py 프로젝트: guardian/alerta
 def get_top10_count(query: Query=None) -> List[Dict[str, Any]]:
     return db.get_topn_count(query, topn=10)