Beispiel #1
0
def stats_package(package=None):
    """
    Return a dictionary of statistics for a package name (optional), or all packages

    :param string package: The package name to provide p_stats for
    :query string stime: The lower bound of the time period to filter on
    :query string ftime: The upper bound of the time period to filter on

    stime and ftime both filter on the release start time.
    Note that standard orlo API filters can be used here as well, not just stime/ftime
    """
    s_stime = request.args.get('stime')
    s_ftime = request.args.get('ftime')

    stime, ftime = None, None
    try:
        if s_stime:
            stime = arrow.get(s_stime)
        if s_ftime:
            ftime = arrow.get(s_ftime)
    except RuntimeError:  # super-class to arrows ParserError, which is not importable
        raise InvalidUsage("A badly formatted datetime string was given")

    if package:
        package_list = [package]
    else:
        package_result = queries.package_list().all()
        # Flatten query result
        package_list = [u[0] for u in package_result]

    package_stats = build_stats_dict('package', package_list, stime=stime, ftime=ftime)

    return jsonify(package_stats)
Beispiel #2
0
def info_package_list():
    """
    Return list of all known packages

    :query platform: Platform to filter on
    """

    platform = request.args.get('platform')
    q = queries.package_list(platform=platform)
    result = q.all()
    packages = [r[0] for r in result]
    return jsonify({'packages': packages}), 200
Beispiel #3
0
def info_package_list():
    """
    Return list of all known packages

    :query platform: Platform to filter on
    """

    platform = request.args.get('platform')
    q = queries.package_list(platform=platform)
    result = q.all()
    packages = [r[0] for r in result]
    return jsonify({'packages': packages}), 200
Beispiel #4
0
def stats_package(package=None):
    """
    Return a dictionary of statistics for a package name (optional), or all packages

    :param string package: The package name to provide p_stats for
    :query string stime: The lower bound of the time period to filter on
    :query string ftime: The upper bound of the time period to filter on

    stime and ftime both filter on the release start time.
    Note that standard orlo API filters can be used here as well, not just stime/ftime
    """
    s_stime = request.args.get('stime')
    s_ftime = request.args.get('ftime')

    stime, ftime = None, None
    try:
        if s_stime:
            stime = arrow.get(s_stime)
        if s_ftime:
            ftime = arrow.get(s_ftime)
    except RuntimeError:  # super-class to arrows ParserError, which is not importable
        raise InvalidUsage("A badly formatted datetime string was given")

    if package:
        package_list = [package]
    else:
        package_result = queries.package_list().all()
        # Flatten query result
        package_list = [u[0] for u in package_result]

    package_stats = build_stats_dict('package',
                                     package_list,
                                     stime=stime,
                                     ftime=ftime)

    return jsonify(package_stats)