コード例 #1
0
def get_history():

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

    try:
        history = db.get_history(query=query, limit=limit)
    except Exception as e:
        return jsonify(status="error", message=str(e)), 500

    for alert in history:
        alert['href'] = absolute_url('/alert/' + alert['id'])

    if len(history) > 0:
        return jsonify(
            status="ok",
            history=history,
            lastTime=history[-1]['updateTime']
        )
    else:
        return jsonify(
            status="ok",
            message="not found",
            history=[],
            lastTIme=query_time
        )
コード例 #2
0
 def get_history(query: Query = None,
                 page=1,
                 page_size=1000) -> List[RichHistory]:
     return [
         RichHistory.from_db(hist)
         for hist in db.get_history(query, page, page_size)
     ]
コード例 #3
0
def get_history(tenant):

    tenant = generateDBName(tenant)

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

    try:
        history = db.get_history(tenant, query=query, limit=limit)
    except Exception as e:
        return jsonify(status="error", message=str(e)), 500

    for alert in history:
        alert['href'] = "%s/%s" % (request.base_url.replace('alerts/history', 'alert'), alert['id'])

    if len(history) > 0:
        return jsonify(
            status="ok",
            history=history,
            lastTime=history[-1]['updateTime']
        )
    else:
        return jsonify(
            status="ok",
            message="not found",
            history=[],
            lastTIme=query_time
        )
コード例 #4
0
ファイル: views.py プロジェクト: wangbodong/alerta
def get_history():

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

    try:
        history = db.get_history(query=query, limit=limit)
    except Exception as e:
        return jsonify(status="error", message=str(e)), 500

    for alert in history:
        alert['href'] = absolute_url('/alert/' + alert['id'])

    if len(history) > 0:
        return jsonify(
            status="ok",
            history=history,
            lastTime=history[-1]['updateTime']
        )
    else:
        return jsonify(
            status="ok",
            message="not found",
            history=[],
            lastTIme=query_time
        )
コード例 #5
0
ファイル: views.py プロジェクト: yekeqiang/alerta
            autoRefresh=Switch.get('auto-refresh-allow').is_on()
        )

@app.route('/alerts/history', methods=['OPTIONS', 'GET'])
@crossdomain(origin='*', headers=['Origin', 'X-Requested-With', 'Content-Type', 'Accept', 'Authorization'])
@auth_required
@jsonp
def get_history():

    try:
        query, _, _, limit, query_time = parse_fields(request)
    except Exception, e:
        return jsonify(status="error", message=str(e)), 400

    try:
        history = db.get_history(query=query, limit=limit)
    except Exception as e:
        return jsonify(status="error", message=str(e)), 500

    for alert in history:
        alert['href'] = "%s/%s" % (request.base_url.replace('alerts/history', 'alert'), alert['id'])

    if len(history) > 0:
        return jsonify(
            status="ok",
            history=history,
            lastTime=history[-1]['updateTime']
        )
    else:
        return jsonify(
            status="ok",
コード例 #6
0
ファイル: alert.py プロジェクト: 3IWOH/alerta
 def get_history(query=None, page=1, page_size=100):
     return [RichHistory.from_db(hist) for hist in db.get_history(query, page, page_size)]
コード例 #7
0
@crossdomain(origin='*',
             headers=[
                 'Origin', 'X-Requested-With', 'Content-Type', 'Accept',
                 'Authorization'
             ])
@auth_required
@jsonp
def get_history():

    try:
        query, _, _, limit, query_time = parse_fields(request)
    except Exception, e:
        return jsonify(status="error", message=str(e)), 400

    try:
        history = db.get_history(query=query, limit=limit)
    except Exception as e:
        return jsonify(status="error", message=str(e)), 500

    for alert in history:
        alert['href'] = "%s/%s" % (request.base_url.replace(
            'alerts/history', 'alert'), alert['id'])

    if len(history) > 0:
        return jsonify(status="ok",
                       history=history,
                       lastTime=history[-1]['updateTime'])
    else:
        return jsonify(status="ok",
                       message="not found",
                       history=[],