Beispiel #1
0
Datei: stats.py Projekt: al4/orlo
def build_stats_dict(field, value_list, platform=None, stime=None, ftime=None):
    """
    Build a dictionary of our stats

    :param field: The field we are build stats for, i.e. user, package, team or
        platform
    :param value_list: The list of values for the field
    :param platform: Filter by platform
    :param datetime ftime: Passed to count_releases
    :param datetime stime: Passed to count_releases
    :return:
    """

    app.logger.debug("Entered build_stats_dict")

    d_stats = {}
    count_releases_args = {
        'stime': stime,
        'ftime': ftime,
        'platform': platform,  # platform can also be the field in the loop below
    }

    for field_value in value_list:
        app.logger.debug("Getting stats for {} {}".format(field, field_value))

        count_releases_args[field] = field_value  # e.g. need to pass user=username

        c_total_successful = queries.count_releases(
                status='SUCCESSFUL', **count_releases_args).all()[0][0]
        c_total_failed = queries.count_releases(
                status='FAILED', **count_releases_args).all()[0][0]
        c_normal_successful = queries.count_releases(
                rollback=False, status='SUCCESSFUL', **count_releases_args).all()[0][0]
        c_normal_failed = queries.count_releases(
                rollback=False, status='FAILED', **count_releases_args).all()[0][0]
        c_rollback_successful = queries.count_releases(
                rollback=True, status='SUCCESSFUL', **count_releases_args).all()[0][0]
        c_rollback_failed = queries.count_releases(
                rollback=True, status='FAILED', **count_releases_args).all()[0][0]

        d_stats[field_value] = {
            'releases': {
                'normal': {
                    'successful': c_normal_successful,
                    'failed': c_normal_failed,
                },
                'rollback': {
                    'successful': c_rollback_successful,
                    'failed': c_rollback_failed,
                },
                'total': {
                    'successful': c_total_successful,
                    'failed': c_total_failed,
                },
            }
        }

    return d_stats
Beispiel #2
0
def build_all_stats_dict(stime=None, ftime=None):
    """
    Build a dictionary of our stats

    :param datetime ftime: Passed to count_releases
    :param datetime stime: Passed to count_releases

    :return:
    """

    app.logger.debug("Entered build_all_stats_dict")

    count_releases_args = {
        'stime': stime,
        'ftime': ftime,
    }

    app.logger.debug("Getting global stats")

    c_total_successful = queries.count_releases(
        status='SUCCESSFUL', **count_releases_args).all()[0][0]
    c_total_failed = queries.count_releases(status='FAILED',
                                            **count_releases_args).all()[0][0]
    c_normal_successful = queries.count_releases(
        rollback=False, status='SUCCESSFUL', **count_releases_args).all()[0][0]
    c_normal_failed = queries.count_releases(rollback=False,
                                             status='FAILED',
                                             **count_releases_args).all()[0][0]
    c_rollback_successful = queries.count_releases(
        rollback=True, status='SUCCESSFUL', **count_releases_args).all()[0][0]
    c_rollback_failed = queries.count_releases(
        rollback=True, status='FAILED', **count_releases_args).all()[0][0]

    d_stats = {
        'global': {
            'releases': {
                'normal': {
                    'successful': c_normal_successful,
                    'failed': c_normal_failed,
                },
                'rollback': {
                    'successful': c_rollback_successful,
                    'failed': c_rollback_failed,
                },
                'total': {
                    'successful': c_total_successful,
                    'failed': c_total_failed,
                },
            }
        }
    }

    return d_stats
Beispiel #3
0
def build_all_stats_dict(stime=None, ftime=None):
    """
    Build a dictionary of our stats

    :param datetime ftime: Passed to count_releases
    :param datetime stime: Passed to count_releases

    :return:
    """

    app.logger.debug("Entered build_all_stats_dict")

    count_releases_args = {
        'stime': stime,
        'ftime': ftime,
    }

    app.logger.debug("Getting global stats")

    c_total_successful = queries.count_releases(
            status='SUCCESSFUL', **count_releases_args).all()[0][0]
    c_total_failed = queries.count_releases(
            status='FAILED', **count_releases_args).all()[0][0]
    c_normal_successful = queries.count_releases(
            rollback=False, status='SUCCESSFUL', **count_releases_args).all()[0][0]
    c_normal_failed = queries.count_releases(
            rollback=False, status='FAILED', **count_releases_args).all()[0][0]
    c_rollback_successful = queries.count_releases(
            rollback=True, status='SUCCESSFUL', **count_releases_args).all()[0][0]
    c_rollback_failed = queries.count_releases(
            rollback=True, status='FAILED', **count_releases_args).all()[0][0]

    d_stats = {
        'global': {
            'releases': {
                'normal': {
                    'successful': c_normal_successful,
                    'failed': c_normal_failed,
                },
                'rollback': {
                    'successful': c_rollback_successful,
                    'failed': c_rollback_failed,
                },
                'total': {
                    'successful': c_total_successful,
                    'failed': c_total_failed,
                },
            }
        }
    }

    return d_stats
Beispiel #4
0
def build_stats_dict(field, value_list, platform=None, stime=None, ftime=None):
    """
    Build a dictionary of our stats

    :param field: The field we are build stats for, i.e. user, package, team or
        platform
    :param value_list: The list of values for the field
    :param platform: Filter by platform
    :param datetime ftime: Passed to count_releases
    :param datetime stime: Passed to count_releases
    :return:
    """

    app.logger.debug("Entered build_stats_dict")

    d_stats = {}
    count_releases_args = {
        'stime': stime,
        'ftime': ftime,
        'platform':
        platform,  # platform can also be the field in the loop below
    }

    for field_value in value_list:
        app.logger.debug("Getting stats for {} {}".format(field, field_value))

        count_releases_args[
            field] = field_value  # e.g. need to pass user=username

        c_total_successful = queries.count_releases(
            status='SUCCESSFUL', **count_releases_args).all()[0][0]
        c_total_failed = queries.count_releases(
            status='FAILED', **count_releases_args).all()[0][0]
        c_normal_successful = queries.count_releases(
            rollback=False, status='SUCCESSFUL',
            **count_releases_args).all()[0][0]
        c_normal_failed = queries.count_releases(
            rollback=False, status='FAILED', **count_releases_args).all()[0][0]
        c_rollback_successful = queries.count_releases(
            rollback=True, status='SUCCESSFUL',
            **count_releases_args).all()[0][0]
        c_rollback_failed = queries.count_releases(
            rollback=True, status='FAILED', **count_releases_args).all()[0][0]

        d_stats[field_value] = {
            'releases': {
                'normal': {
                    'successful': c_normal_successful,
                    'failed': c_normal_failed,
                },
                'rollback': {
                    'successful': c_rollback_successful,
                    'failed': c_rollback_failed,
                },
                'total': {
                    'successful': c_total_successful,
                    'failed': c_total_failed,
                },
            }
        }

    return d_stats