Beispiel #1
0
def get_commit_ordered_by_worker(request, commit_id):
    """ Returns html for the commit executions ordered by worker """
    if request.method == 'GET':
        commit_entry = GitCommitEntry.objects.filter(id=commit_id).first()
        if not commit_entry:
            return res.get_template_data(request, 'presenter/not_found.html',
                                         {})

        ret = BenchmarkExecutionController.get_bench_execs_ordered_by_worker(
            commit_entry)

        if ret['commit']['parent']['id'] != None:
            com_id = ret['commit']['parent']['id']
            ret['commit']['parent'][
                'url'] = ViewUrlGenerator.get_commit_ordered_by_worker_url(
                    com_id)

        if ret['commit']['son']['id'] != None:
            com_id = ret['commit']['son']['id']
            ret['commit']['son'][
                'url'] = ViewUrlGenerator.get_commit_ordered_by_worker_url(
                    com_id)

        for worker in ret['workers']:
            executions = []
            for execution in worker['executions']:
                obj = {}
                obj['id'] = execution['id']
                obj['name'] = execution['name']
                obj['url'] = ViewUrlGenerator.get_benchmark_execution_relevant_url(
                    execution['id'])
                executions.append(obj)
            worker['executions'] = executions

        data = {}
        data['commit_data'] = ret
        data['menu'] = ViewPrepareObjects.prepare_menu_for_html([])

        return res.get_template_data(request,
                                     'presenter/commit_by_workers.html', data)
    else:
        return res.get_template_data(request, 'presenter/not_found.html', {})
def prepare_branches_for_html(project_id, branches):
    """ Prepare branch data adding urls before html """
    ret_branches = []
    for branch in branches:
        for commit in branch['commits']:
            commit['url'] = {}
            commit['url'][
                'executions'] = ViewUrlGenerator.get_commit_ordered_by_worker_url(
                    commit['id'])

        branch['url'] = {}
        branch['url'][
            'single'] = ViewUrlGenerator.get_project_branch_single_url(
                project_id, branch['id'])
        branch['url'][
            'links'] = ViewUrlGenerator.get_project_branch_single_links_url(
                project_id, branch['id'])
        ret_branches.append(branch)
    return ret_branches