Пример #1
0
def update_interval_jobs(begin, end):
    jobs = st.get_jobs(begin, end)
    store_calc(st, 'metrics:total-jobs', begin, len(jobs))

    results = [(j, st.db.get('frag:jobs:-{}-:result'.format(j))) for j in jobs]
    verdicts = filter(lambda (_, v): v is not None,
                      [(j, st.db.get('frag:results:-{}-:'.format(r))) for (j, r) in results])
    passed_jobs = [j for (j, v) in verdicts if 'passed' in v]
    failed_jobs = [j for (j, v) in verdicts if 'failed' in v]
    store_calc(st, 'metrics:total-passed-jobs', begin, len(passed_jobs))
    store_calc(st, 'metrics:total-failed-jobs', begin, len(failed_jobs))
Пример #2
0
def update_interval_developers(begin, end):
    all_devs = st.get_developers(begin, end)
    devs = map(lambda x: x[0], all_devs)
    externals = map(lambda x: x[0], filter(lambda x: x[1], all_devs))
    total_repo_devs = {}
    total_repo_externals = {}
    repo_product = {}
    repo_project = {}
    product_devs = {}
    project_devs = {}
    product_externals = {}
    project_externals = {}
    products = st.get_products()
    projects = set([])
    for product in products:
        prod_projects = st.get_product_projects(product)
        product_devs[product] = set([])
        product_externals[product] = set([])
        for project in prod_projects:
            project_devs[project] = set([])
            project_externals[project] = set([])
            projects.add(project)
            repos = st.get_project_repositories(project)
            for repo in repos:
                if repo not in repo_product:
                    repo_product[repo] = set([])
                if repo not in repo_project:
                    repo_project[repo] = set([])
                repo_product[repo].add(product)
                repo_project[repo].add(project)

    if len(externals):
        store_calc(st, 'metrics:total-externals', begin, externals)
    if len(devs):
        store_calc(st, 'metrics:total-developers', begin, devs)
        for uid in devs:
            value = len(st.get_commits(begin, end, uid=uid))
            store_calc(st, 'metrics:total-member-commits:{}'.format(uid), begin, value)
            for rid in st.get_all_developer_repos(uid):
                value = len(st.get_commits(begin, end, uid=uid, rid=rid))
                if rid not in total_repo_devs:
                    total_repo_devs[rid] = set([])
                if rid not in total_repo_externals:
                    total_repo_externals[rid] = set([])
                if value:
                    total_repo_devs[rid].add(uid)
                    if uid in externals:
                        total_repo_externals[rid].add(uid)
                        if rid in repo_product:
                            map(lambda _: product_externals.get(_).add(uid), repo_product[rid])
                        if rid in repo_project:
                            map(lambda _: project_externals.get(_).add(uid), repo_project[rid])
                    if rid in repo_product:
                        map(lambda _: product_devs.get(_).add(uid), repo_product[rid])
                    if rid in repo_project:
                        map(lambda _: project_devs.get(_).add(uid), repo_project[rid])
                store_calc(st, 'metrics:total-repo-member-commits:{}:{}'.format(rid, uid), begin, value)
        [store_calc(st, 'metrics:total-repo-developers:{}'.format(rid), begin, list(total_repo_devs[rid])) for rid in
         filter(lambda x: len(total_repo_devs[x]), total_repo_devs)]
        [store_calc(st, 'metrics:total-repo-externals:{}'.format(rid), begin, list(total_repo_externals[rid])) for rid
         in
         filter(lambda x: len(total_repo_externals[x]), total_repo_externals)]

        [store_calc(st, 'metrics:total-product-developers:{}'.format(x), begin, list(product_devs[x])) for x in
         products]
        [store_calc(st, 'metrics:total-product-externals:{}'.format(x), begin, list(product_externals[x])) for x in
         products]
        [store_calc(st, 'metrics:total-project-developers:{}'.format(x), begin, list(project_devs[x])) for x in
         projects]
        [store_calc(st, 'metrics:total-project-externals:{}'.format(x), begin, list(project_externals[x])) for x in
         projects]
Пример #3
0
def update_interval_branches(begin, end):
    value = len(st.get_branches(begin, end))
    store_calc(st, 'metrics:total-branches', begin, value)
Пример #4
0
def update_interval_commits(begin, end):
    value = len(st.get_commits(begin, end))
    store_calc(st, 'metrics:total-commits', begin, value)
Пример #5
0
def update_interval_repo_metrics(begin, end):
    total_commits = {}
    total_branches = {}
    for rid in st.get_repositories():
        value = len(st.get_commits(begin, end, rid=rid))
        total_commits[rid] = value
        store_calc(st, 'metrics:total-repo-commits:{}'.format(rid), begin, value)

        value = len(st.get_branches(begin, end, rid=rid))
        store_calc(st, 'metrics:total-repo-branches:{}'.format(rid), begin, value)
        total_branches[rid] = value

    product_repos = {}

    for product in st.get_products():
        product_commits = 0
        product_branches = 0
        projects = st.get_product_projects(product)
        if product not in product_repos:
            product_repos[product] = set([])
        for project in projects:
            project_commits = 0
            project_branches = 0
            av_repos = set.intersection(set(total_commits.keys()), st.get_project_repositories(project))
            for rid in av_repos:
                if rid not in product_repos[product]:
                    product_repos[product].add(rid)
                    product_commits += total_commits[rid]
                    product_branches += total_branches[rid]
                project_commits += total_commits[rid]
                project_branches += total_branches[rid]
            store_calc(st, 'metrics:total-project-commits:{}'.format(project), begin, project_commits)
            store_calc(st, 'metrics:total-project-branches:{}'.format(project), begin, project_branches)

        store_calc(st, 'metrics:total-product-commits:{}'.format(product), begin, product_commits)
        store_calc(st, 'metrics:total-product-branches:{}'.format(product), begin, product_branches)
Пример #6
0
def update_interval_repo_metrics(begin, end):
    totals = {}
    passed = {}
    failed = {}
    for rid in st.get_repositories():
        jobs = st.get_jobs(begin, end, rid=rid)
        totals[rid] = len(jobs)
        store_calc(st, 'metrics:total-repo-jobs:{}'.format(rid), begin, totals[rid])

        results = [(j, st.db.get('frag:jobs:-{}-:result'.format(j))) for j in jobs]
        verdicts = filter(lambda (_, v): v is not None,
                          [(j, st.db.get('frag:results:-{}-:'.format(r))) for (j, r) in results])
        passed_jobs = [j for (j, v) in verdicts if 'passed' in v]
        passed[rid] = len(passed_jobs)
        failed_jobs = [j for (j, v) in verdicts if 'failed' in v]
        failed[rid] = len(failed_jobs)
        store_calc(st, 'metrics:total-passed-repo-jobs:{}'.format(rid), begin, passed[rid])
        store_calc(st, 'metrics:total-failed-repo-jobs:{}'.format(rid), begin, failed[rid])

    for product in st.get_products():
        product_total = 0
        product_passed = 0
        product_failed = 0
        projects = st.get_product_projects(product)
        for project in projects:
            project_total = 0
            project_passed = 0
            project_failed = 0
            for rid in set.intersection(set(totals.keys()), st.get_project_repositories(project)):
                project_total += totals[rid]
                project_passed += passed[rid]
                project_failed += failed[rid]
            store_calc(st, 'metrics:total-project-jobs:{}'.format(project), begin, project_total)
            store_calc(st, 'metrics:total-passed-project-jobs:{}'.format(project), begin, project_passed)
            store_calc(st, 'metrics:total-failed-project-jobs:{}'.format(project), begin, project_failed)
            product_total += project_total
            product_passed += project_passed
            product_failed += project_failed

        store_calc(st, 'metrics:total-product-jobs:{}'.format(product), begin, product_total)
        store_calc(st, 'metrics:total-passed-product-jobs:{}'.format(product), begin, product_passed)
        store_calc(st, 'metrics:total-failed-product-jobs:{}'.format(product), begin, product_failed)