当前位置: 首页>>代码示例>>Python>>正文


Python Alert.get_counts_by_status方法代码示例

本文整理汇总了Python中alerta.models.alert.Alert.get_counts_by_status方法的典型用法代码示例。如果您正苦于以下问题:Python Alert.get_counts_by_status方法的具体用法?Python Alert.get_counts_by_status怎么用?Python Alert.get_counts_by_status使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在alerta.models.alert.Alert的用法示例。


在下文中一共展示了Alert.get_counts_by_status方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get_counts

# 需要导入模块: from alerta.models.alert import Alert [as 别名]
# 或者: from alerta.models.alert.Alert import get_counts_by_status [as 别名]
def get_counts():
    query = qb.from_params(request.args)
    severity_count = Alert.get_counts_by_severity(query)
    status_count = Alert.get_counts_by_status(query)

    return jsonify(
        status="ok",
        total=sum(severity_count.values()),
        severityCounts=severity_count,
        statusCounts=status_count
    )
开发者ID:kattunga,项目名称:alerta,代码行数:13,代码来源:alerts.py

示例2: search_alerts

# 需要导入模块: from alerta.models.alert import Alert [as 别名]
# 或者: from alerta.models.alert.Alert import get_counts_by_status [as 别名]
def search_alerts():
    query_time = datetime.utcnow()
    query = qb.from_params(request.args, query_time)
    severity_count = Alert.get_counts_by_severity(query)
    status_count = Alert.get_counts_by_status(query)

    total = sum(severity_count.values())
    paging = Page.from_params(request.args, total)

    alerts = Alert.find_all(query, paging.page, paging.page_size)

    if alerts:
        return jsonify(
            status="ok",
            page=paging.page,
            pageSize=paging.page_size,
            pages=paging.pages,
            more=paging.has_more,
            alerts=[alert.serialize for alert in alerts],
            total=total,
            statusCounts=status_count,
            severityCounts=severity_count,
            lastTime=max([alert.last_receive_time for alert in alerts]),
            autoRefresh=Switch.find_by_name('auto-refresh-allow').is_on
        )
    else:
        return jsonify(
            status="ok",
            message="not found",
            page=paging.page,
            pageSize=paging.page_size,
            pages=0,
            more=False,
            alerts=[],
            total=0,
            severityCounts=severity_count,
            statusCounts=status_count,
            lastTime=query_time,
            autoRefresh=Switch.find_by_name('auto-refresh-allow').is_on
        )
开发者ID:kattunga,项目名称:alerta,代码行数:42,代码来源:alerts.py


注:本文中的alerta.models.alert.Alert.get_counts_by_status方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。