def get_benchmark_execution_complete(request, bench_exec_id):
    """ Returns a benchmark execution """
    data = {}
    data['menu'] = ViewPrepareObjects.prepare_menu_for_html([])

    exec_entry = BenchmarkExecutionEntry.objects.filter(
        id=bench_exec_id).first()

    if exec_entry is None:
        return res.get_template_data(request, 'presenter/not_found.html', data)

    obj = exec_entry.as_object()
    data[
        'results'] = ViewPrepareObjects.prepare_results_from_bench_exec_to_html(
            obj)
    data['url'] = {}
    data['url'][
        'invalidate'] = ViewUrlGenerator.get_benchmark_execution_invalidate_url(
            exec_entry.id)
    data['url'][
        'relevant'] = ViewUrlGenerator.get_benchmark_execution_relevant_url(
            exec_entry.id)

    return res.get_template_data(
        request, 'presenter/benchmark_execution_complete.html', data)
def get_project_single_branch(request, project_id, branch_id):
    """ Display all the branches of a project """
    if request.method != 'GET':
        return res.get_template_data(request, 'presenter/not_found.html', {})

    project_entry = BluesteelProjectEntry.objects.filter(id=project_id).first()
    if project_entry is None:
        return res.get_template_data(request, 'presenter/not_found.html', {})

    git_project = GitProjectEntry.objects.filter(
        id=project_entry.git_project.id).first()
    if git_project is None:
        return res.get_template_data(request, 'presenter/not_found.html', {})

    branch_entry = GitBranchEntry.objects.filter(id=branch_id,
                                                 project=git_project).first()
    if branch_entry is None:
        return res.get_template_data(request, 'presenter/not_found.html', {})

    branches = BluesteelProjectController.get_project_single_git_branch_data(
        git_project, branch_entry, BRANCH_COMMIT_DEPTH)
    branches = BenchmarkExecutionController.add_bench_exec_completed_to_branches(
        branches)

    data = {}
    data['branches'] = ViewPrepareObjects.prepare_branches_for_html(
        project_entry.id, branches)
    data['url'] = {}
    data['url'][
        'change_merge_target'] = ViewUrlGenerator.get_change_merge_target_url(
            project_entry.id)
    data['menu'] = ViewPrepareObjects.prepare_menu_for_html([])

    return res.get_template_data(request, 'presenter/project_branches.html',
                                 data)
Exemple #3
0
def get_feed_reports_from_worker(request, worker_id, page_index):
    """ Returns a single item list of all the feeds produced by a worker """
    if request.method != 'GET':
        return res.get_only_get_allowed({})

    feed_entries = FeedEntry.objects.filter(worker__id=worker_id).order_by('-created_at')

    page = Page(FEED_REPORT_ITEMS_PER_PAGE, page_index)
    pager = Paginator(feed_entries, page.items_per_page)
    current_page = pager.page(page.page_index)
    feed_entries = current_page.object_list
    page_indices = pag.get_pagination_indices(page, PAGINATION_HALF_RANGE, pager.num_pages)

    items = []
    for report in feed_entries:
        obj = {}
        obj['name'] = 'REPORT {0}'.format(report.id)
        obj['url'] = ViewUrlGenerator.get_feed_report_url(report.id)
        items.append(obj)

    data = {}
    data['menu'] = ViewPrepareObjects.prepare_menu_for_html([])
    data['controls'] = get_feed_controls(worker_id, KEEP_YOUNG_COUNT)
    data['pagination'] = ViewPrepareObjects.prepare_pagination_feed_reports(worker_id, page_indices)
    data['items'] = items

    return res.get_template_data(request, 'presenter/single_item_list.html', data)
def get_project_branches(request, project_id, commit_depth, page_index):
    """ Display all the branches of a project """
    if request.method != 'GET':
        return res.get_template_data(request, 'presenter/not_found.html', {})

    project_entry = BluesteelProjectEntry.objects.filter(id=project_id).first()
    if project_entry is None:
        return res.get_template_data(request, 'presenter/not_found.html', {})

    project = GitProjectEntry.objects.filter(
        id=project_entry.git_project.id).first()
    if project is None:
        return res.get_template_data(request, 'presenter/not_found.html', {})

    page = Page(PROJECTS_BRANCHES_PER_PAGE, page_index)
    branches, page_indices = BluesteelProjectController.get_project_git_branch_data(
        page, project, commit_depth)
    branches = BenchmarkExecutionController.add_bench_exec_completed_to_branches(
        branches)

    pagination = ViewPrepareObjects.prepare_pagination_branches(
        project_entry.id, commit_depth, page_indices)

    data = {}
    data['branches'] = ViewPrepareObjects.prepare_branches_for_html(
        project_entry.id, branches)
    data['url'] = {}
    data['url'][
        'change_merge_target'] = ViewUrlGenerator.get_change_merge_target_url(
            project_entry.id)
    data['menu'] = ViewPrepareObjects.prepare_menu_for_html([])
    data['pagination'] = pagination

    return res.get_template_data(request, 'presenter/project_branches.html',
                                 data)
def get_benchmark_execution_window(request, bench_exec_id):
    """ Returns a window of benchmark executions centered on bench_exe_id """
    if request.method != 'GET':
        return res.get_template_data(request, 'presenter/not_found.html', {})

    bench_exec = BenchmarkExecutionEntry.objects.filter(
        id=bench_exec_id).first()
    if not bench_exec:
        return res.get_template_data(request, 'presenter/not_found.html', {})

    commit_info = bench_exec.commit.as_object()

    exec_stacked = BenchmarkExecutionController.get_benchmark_execution_window(
        bench_exec, BENCH_EXEC_WINDOW_HALF)
    executions = ViewPrepareObjects.prepare_stacked_executions_url_field(
        request.get_host(), exec_stacked)
    executions = ViewPrepareObjects.prepare_windowed_executions_colors(
        executions, commit_info['hash'])
    executions = ViewPrepareObjects.prepare_stacked_executions_json_field(
        executions)

    data = {}
    data['commit_info'] = commit_info
    data['stacked_executions'] = executions
    data['menu'] = ViewPrepareObjects.prepare_menu_for_html([])

    return res.get_template_data(request,
                                 'presenter/benchmark_execution_stacked.html',
                                 data)
def get_projects(request, page_index):
    """ Display all branch names """
    if request.method != 'GET':
        return res.get_template_data(request, 'presenter/not_found.html', {})

    page = Page(PROJECTS_ITEMS_PER_PAGE, page_index)
    projects, page_indices = BluesteelProjectController.get_paginated_projects_as_objects(
        page)

    items = []
    for project in projects:
        obj = {}
        obj['name'] = project['name']
        obj['url'] = {}
        obj['url']['branches'] = ViewUrlGenerator.get_project_branches_url(
            project['id'], BRANCH_COMMIT_DEPTH, 1)
        obj['url']['edit'] = ViewUrlGenerator.get_project_edit_url(
            project['id'])
        items.append(obj)

    pagination = ViewPrepareObjects.prepare_pagination_project(page_indices)

    data = {}
    data['projects'] = items
    data['menu'] = ViewPrepareObjects.prepare_menu_for_html([])
    data['pagination'] = pagination

    return res.get_template_data(request, 'presenter/project_list.html', data)
Exemple #7
0
def get_worker_all(request, page_index):
    """ Returns html for the workers page """
    if request.method != 'GET':
        return res.get_only_get_allowed({})

    worker_entries = WorkerEntry.objects.all().order_by('name')

    page = Page(WORKER_ITEMS_PER_PAGE, page_index)
    pager = Paginator(worker_entries, page.items_per_page)
    current_page = pager.page(page.page_index)
    worker_entries = current_page.object_list
    page_indices = pag.get_pagination_indices(page, PAGINATION_HALF_RANGE,
                                              pager.num_pages)

    workers = get_workers_with_benchmark_info(worker_entries)

    control = {}
    control['name'] = '  Download Worker'
    control['link'] = ViewUrlGenerator.get_download_worker_url()
    control['icon'] = 'fa fa-arrow-down'
    control['onclick'] = 'window.location="{0}"'.format(control['link'])

    pagination = ViewPrepareObjects.prepare_pagination_workers(page_indices)

    data = {}
    data['menu'] = ViewPrepareObjects.prepare_menu_for_html([])
    data['pagination'] = pagination
    data['workers'] = ViewPrepareObjects.prepare_workers_for_html(workers)
    data['controls'] = []
    data['controls'].append(control)

    return res.get_template_data(request, 'presenter/worker_all.html', data)
def get_benchmark_executions_stacked(request, project_id, branch_id,
                                     definition_id, worker_id, page_index):
    """ Returns benchmark executions stacked and paginated """
    if request.method != 'GET':
        return res.get_template_data(request, 'presenter/not_found.html', {})

    project = BluesteelProjectEntry.objects.filter(id=project_id).first()
    if project is None:
        return res.get_template_data(request, 'presenter/not_found.html', {})

    git_project = GitProjectEntry.objects.filter(
        id=project.git_project.id).first()
    if git_project is None:
        return res.get_template_data(request, 'presenter/not_found.html', {})

    branch = GitBranchEntry.objects.filter(id=branch_id,
                                           project=git_project).first()
    if branch is None:
        return res.get_template_data(request, 'presenter/not_found.html', {})

    definition = BenchmarkDefinitionEntry.objects.filter(
        id=definition_id, project=project).first()
    if definition is None:
        return res.get_template_data(request, 'presenter/not_found.html', {})

    worker = WorkerEntry.objects.filter(id=worker_id).first()
    if worker is None:
        return res.get_template_data(request, 'presenter/not_found.html', {})

    page = Page(BENCH_EXEC_ITEMS_PER_PAGE, page_index)
    commit_hashes, pagination = BenchmarkExecutionController.get_bench_exec_commits_paginated(
        git_project, branch, page)

    pagination = ViewPrepareObjects.prepare_pagination_bench_stacked(
        project_id, branch_id, definition_id, worker_id, pagination)

    data_exec = BenchmarkExecutionController.get_stacked_executions_from_branch(
        git_project, branch, commit_hashes, definition, worker)

    exec_stacked = BenchmarkExecutionController.get_stacked_data_separated_by_id(
        data_exec)

    executions = ViewPrepareObjects.prepare_stacked_executions_url_field(
        request.get_host(), exec_stacked)
    executions = ViewPrepareObjects.prepare_stacked_executions_json_field(
        executions)

    data = {}
    data['stacked_executions'] = executions
    data['pagination'] = pagination
    data['menu'] = ViewPrepareObjects.prepare_menu_for_html([])

    return res.get_template_data(request,
                                 'presenter/benchmark_execution_stacked.html',
                                 data)
def get_benchmark_executions_stacked_quick(request, project_id, branch_id,
                                           definition_id, worker_id):
    """ Returns benchmark executions stacked and paginated """
    if request.method == 'GET':
        project = BluesteelProjectEntry.objects.filter(id=project_id).first()
        if project is None:
            return res.get_response(404, 'BluesteelProject not found', {})

        git_project = GitProjectEntry.objects.filter(
            id=project.git_project.id).first()
        if git_project is None:
            return res.get_response(404, 'GitProject not found', {})

        branch = GitBranchEntry.objects.filter(id=branch_id,
                                               project=git_project).first()
        if branch is None:
            return res.get_response(404, 'GitBranchEntry not found', {})

        definition = BenchmarkDefinitionEntry.objects.filter(
            id=definition_id, project=project).first()
        if definition is None:
            return res.get_response(404, 'BenchmarkDefinitionEntry not found',
                                    {})

        worker = WorkerEntry.objects.filter(id=worker_id).first()
        if worker is None:
            return res.get_response(404, 'WorkerEntry not found', {})

        page = Page(BENCH_QUICK_ITEMS, BENCH_QUICK_DEFAULT_PAGE)
        commit_hashes_list, pagination = BenchmarkExecutionController.get_bench_exec_commits_paginated(
            git_project, branch, page)
        del pagination

        data_exec = BenchmarkExecutionController.get_stacked_executions_from_branch(
            git_project, branch, commit_hashes_list, definition, worker)

        exec_stacked = BenchmarkExecutionController.get_stacked_data_separated_by_id(
            data_exec)

        execs = ViewPrepareObjects.prepare_stacked_executions_url_field(
            request.get_host(), exec_stacked)
        execs = ViewPrepareObjects.prepare_stacked_executions_json_field(execs)

        data = {}
        data['stacked_executions'] = execs

        return res.get_response(200, 'Benchmark Execution Stacked', data)
    else:
        return res.get_only_get_allowed({})
Exemple #10
0
def get_layout_editable(request, layout_id):
    """ Returns html for the layout editable page """
    if request.method != 'GET':
        return res.get_template_data(request, 'presenter/not_found.html', {})

    layout = BluesteelLayoutEntry.objects.filter(id=layout_id).first()

    data = {}
    data['layout'] = layout.as_object()
    data['layout'] = ViewPrepareObjects.prepare_layout_for_html(data['layout'])
    data['menu'] = ViewPrepareObjects.prepare_menu_for_html([])

    for project in data['layout']['projects']:
        project = ViewPrepareObjects.prepare_project_for_html(project)

    return res.get_template_data(request, 'presenter/layout_edit.html', data)
Exemple #11
0
def get_main(request):
    """ Returns html for the main page """

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

    return res.get_template_data(request, 'presenter/main.html', data)
def get_benchmark_definition_edit(request, definition_id):
    """ Returns html for the benchmark definition edit page """
    data = {}
    data['menu'] = ViewPrepareObjects.prepare_menu_for_html([])
    data['controls'] = get_definition_controls()

    def_entry = BenchmarkDefinitionController.get_benchmark_definition(definition_id)

    if def_entry is None:
        return res.get_template_data(request, 'presenter/not_found.html', data)

    obj = def_entry
    obj['url'] = {}
    obj['url']['save'] = ViewUrlGenerator.get_save_benchmark_definition_url(definition_id)
    obj['url']['delete'] = ViewUrlGenerator.get_confirm_delete_benchmark_def_url(definition_id)
    obj['url']['project_info'] = ViewUrlGenerator.get_editable_projects_info_url()
    obj['layout_selection'] = get_layout_selection(def_entry['layout']['id'])
    obj['project_selection'] = get_project_selection(def_entry['layout']['id'], def_entry['project']['id'])

    names_and_sel = []
    count = 0
    for name in obj['priority']['names']:
        nas = {}
        nas['name'] = name
        nas['selected'] = obj['priority']['current'] == count
        count = count +1
        names_and_sel.append(nas)
    obj['priority']['names'] = names_and_sel


    data['definition'] = obj

    return res.get_template_data(request, 'presenter/benchmark_definition_edit.html', data)
def get_benchmark_definition(request, definition_id):
    """ Returns html for the benchmark definition page """
    data = {}
    data['menu'] = ViewPrepareObjects.prepare_menu_for_html([])
    data['controls'] = get_definition_controls()

    def_entry = BenchmarkDefinitionController.get_benchmark_definition(definition_id)

    if def_entry is None:
        return res.get_template_data(request, 'presenter/not_found.html', data)

    obj = def_entry
    obj['url'] = {}
    obj['url']['edit'] = ViewUrlGenerator.get_edit_benchmark_definition_url(definition_id)
    obj['url']['duplicate'] = ViewUrlGenerator.get_duplicate_benchmark_definition_url(definition_id)
    obj['url']['project_info'] = ViewUrlGenerator.get_editable_projects_info_url()
    obj['layout_selection'] = get_layout_selection(def_entry['layout']['id'])
    obj['project_selection'] = get_project_selection(def_entry['layout']['id'], def_entry['project']['id'])

    # Translate priority number to name.
    obj['priority']['name'] = obj['priority']['names'][obj['priority']['current']]

    data['definition'] = obj

    return res.get_template_data(request, 'presenter/benchmark_definition.html', data)
def get_benchmark_executions_quick_page(request):
    """ Returns the view for the executions quick page """
    if request.method != 'GET':
        return res.get_template_data(request, 'presenter/not_found.html', {})

    control1 = {}
    control1['name'] = ' Quick View'
    control1['link'] = ViewUrlGenerator.get_benchmark_executions_quick_url()
    control1['icon'] = 'fa fa-bar-chart'
    control1['onclick'] = 'window.location="{0}"'.format(control1['link'])

    control2 = {}
    control2['name'] = ' Per Branch'
    control2['link'] = ViewUrlGenerator.get_benchmark_executions_branches_url()
    control2['icon'] = 'fa fa-code-fork'
    control2['onclick'] = 'window.location="{0}"'.format(control2['link'])

    data = {}
    data['menu'] = ViewPrepareObjects.prepare_menu_for_html([])
    data['controls'] = []
    data['controls'].append(control1)
    data['controls'].append(control2)

    return res.get_template_data(request,
                                 'presenter/benchmark_executions_quick.html',
                                 data)
def get_project_editable(request, project_id):
    """ Returns html for the project editable page """
    if request.method != 'GET':
        return res.get_template_data(request, 'presenter/not_found.html', {})

    project = BluesteelProjectEntry.objects.filter(id=project_id).first()

    if project is None:
        return res.get_template_data(request, 'presenter/not_found.html', {})

    data = {}
    data['project'] = project.as_object()
    data['project'] = ViewPrepareObjects.prepare_project_for_html(
        data['project'])
    data['menu'] = ViewPrepareObjects.prepare_menu_for_html([])

    return res.get_template_data(request, 'presenter/project_edit.html', data)
Exemple #16
0
def get_worker_reports(request, worker_id):
    """ Returns html for the worker reports page """
    if request.method != 'GET':
        return res.get_only_get_allowed({})

    worker = WorkerEntry.objects.filter(id=worker_id).first()
    if not worker:
        return res.get_template_data(request, 'presenter/not_found.html', {})

    report_entries = CommandGroupEntry.objects.filter(user=worker.user)
    reports = []
    for report in report_entries:
        reports.append(report.as_object())

    data = {}
    data['menu'] = ViewPrepareObjects.prepare_menu_for_html([])
    data['reports'] = ViewPrepareObjects.prepare_reports_for_html(reports)

    return res.get_template_data(request, 'presenter/worker_report.html', data)
def get_benchmark_definition_all(request, page_index):
    """ Returns html for the benchmark definition page """

    (definitions, page_indices) = BenchmarkDefinitionController.get_benchmark_definitions_with_pagination(
        DEFINITION_ITEMS_PER_PAGE,
        page_index,
        PAGINATION_HALF_RANGE
    )

    for definition in definitions:
        definition['url'] = {}
        definition['url']['single'] = ViewUrlGenerator.get_benchmark_definition_url(definition['id'])

    data = {}
    data['definitions'] = definitions
    data['menu'] = ViewPrepareObjects.prepare_menu_for_html([])
    data['pagination'] = ViewPrepareObjects.prepare_pagination_bench_definitions(page_indices)
    data['controls'] = get_definition_controls()
    return res.get_template_data(request, 'presenter/benchmark_definition_all.html', data)
Exemple #18
0
def get_worker(request, worker_id):
    """ Returns html for the workers page """
    if request.method != 'GET':
        return res.get_only_get_allowed({})

    worker_entries = WorkerEntry.objects.filter(id=worker_id)
    workers = get_workers_with_benchmark_info(worker_entries)

    control = {}
    control['name'] = '  Download Worker'
    control['link'] = ViewUrlGenerator.get_download_worker_url()
    control['icon'] = 'fa fa-arrow-down'
    control['onclick'] = 'window.location="{0}"'.format(control['link'])

    data = {}
    data['menu'] = ViewPrepareObjects.prepare_menu_for_html([])
    data['workers'] = ViewPrepareObjects.prepare_workers_for_html(workers)
    data['controls'] = []
    data['controls'].append(control)

    return res.get_template_data(request, 'presenter/worker.html', data)
def get_notifications_of_git_project(request, git_project_id):
    """ Returns html for the benchmark definition page """
    data = {}
    data['menu'] = ViewPrepareObjects.prepare_menu_for_html([])
    data['controls'] = get_notification_controls()

    git_projects = GitProjectEntry.objects.all().order_by('-id')

    projects = []
    for git_project in git_projects:
        project = {}
        project['name'] = git_project.name
        project['url'] = ViewUrlGenerator.get_notification_url(git_project.id)
        project['selected'] = git_project.id == git_project_id
        projects.append(project)


    waivers = BenchmarkFluctuationWaiverEntry.objects.filter(
        git_user__project__id=git_project_id).order_by('-git_user__name')

    entries = []
    for waiver in waivers:
        entry = {}
        entry['name'] = waiver.git_user.name
        entry['email'] = waiver.git_user.email
        entry['notification_allowed'] = waiver.notification_allowed
        entry['url'] = {}
        entry['url']['allow'] = ViewUrlGenerator.get_notification_allow_url(waiver.id)
        entry['url']['deny'] = ViewUrlGenerator.get_notification_deny_url(waiver.id)
        entries.append(entry)

    data = {}
    data['menu'] = ViewPrepareObjects.prepare_menu_for_html([])
    data['controls'] = get_notification_controls()
    data['projects'] = projects
    data['entries'] = entries

    return res.get_template_data(request, 'presenter/benchmark_notification.html', data)
Exemple #20
0
def get_feed_report(request, feed_report_id):
    """ Returns html for the worker reports page """
    if request.method != 'GET':
        return res.get_only_get_allowed({})

    feed = FeedEntry.objects.filter(id=feed_report_id).first()
    if not feed:
        return res.get_template_data(request, 'presenter/not_found.html', {})
    data = {}
    data['menu'] = ViewPrepareObjects.prepare_menu_for_html([])
    data['report'] = feed.as_object()

    data['report'] = trim_report(data['report'])

    return res.get_template_data(request, 'presenter/worker_report.html', data)
Exemple #21
0
def get_layouts(request, page_index):
    """ Returns html for the layout page """
    page = Page(LAYOUT_ITEMS_PER_PAGE, page_index)
    layout_list, page_indices = BluesteelLayoutController.get_paginated_layouts_as_objects(page)

    for layout in layout_list:
        layout = ViewPrepareObjects.prepare_layout_for_html(layout)

    control = {}
    control['name'] = '  Add Layout'
    control['link'] = ViewUrlGenerator.get_layout_create_url()
    control['icon'] = 'fa fa-plus'
    control['onclick'] = 'executeAndRedirect(\'{0}\', \'\');'.format(control['link'])

    pagination = ViewPrepareObjects.prepare_pagination_layout(page_indices)

    data = {}
    data['layout_list'] = layout_list
    data['menu'] = ViewPrepareObjects.prepare_menu_for_html([])
    data['pagination'] = pagination
    data['controls'] = []
    data['controls'].append(control)

    return res.get_template_data(request, 'presenter/layout.html', data)
Exemple #22
0
def acquire_benchmark_execution(request):
    """ Acquire the next available benchmark execution posible """
    if request.method != 'POST':
        return res.get_only_post_allowed({})

    BenchmarkExecutionController.try_populate_executions(
        POPULATE_EXECUTIONS_INC_COUNT)
    next_execution = BenchmarkExecutionController.get_earliest_available_execution(
        request.user)

    if next_execution is None:
        return res.get_response(404, 'Next Execution not found', {})

    execution = ViewPrepareObjects.prepare_benchmark_execution_for_html(
        next_execution.as_object(), request.get_host())
    return res.get_response(200, 'Next Execution', execution)
def get_benchmark_definition_confirm_delete(request, definition_id):
    """ Confirm benchmark definition deletion """
    if request.method == 'GET':
        bench_def = BenchmarkDefinitionEntry.objects.filter(id=definition_id).first()
        if bench_def is None:
            return res.get_template_data(request, 'presenter/not_found.html', {})

        data = {}
        data['confirm'] = {}
        data['confirm']['title'] = 'Delete Benchmark Definition'
        data['confirm']['text'] = 'Are you sure you want to delete this Benchmark Definition ?'
        data['confirm']['url'] = {}
        data['confirm']['url']['accept'] = ViewUrlGenerator.get_delete_benchmark_definition_url(bench_def.id)
        data['confirm']['url']['cancel'] = ViewUrlGenerator.get_edit_benchmark_definition_url(bench_def.id)
        data['menu'] = ViewPrepareObjects.prepare_menu_for_html([])

        return res.get_template_data(request, 'presenter/confirm.html', data)
    else:
        return res.get_only_get_allowed({})
Exemple #24
0
def confirm_wipe(request, layout_id):
    """ Confirm layout deletion """
    if request.method != 'GET':
        return res.get_only_get_allowed({})

    layout_entry = BluesteelLayoutEntry.objects.filter(id=layout_id).first()
    if layout_entry is None:
        return res.get_response(404, 'Bluesteel layout not found', {})

    data = {}
    data['confirm'] = {}
    data['confirm']['title'] = 'Wipe layout'
    data['confirm']['text'] = 'Are you sure you want to wipe this Layout\'s data ?'
    data['confirm']['url'] = {}
    data['confirm']['url']['accept'] = ViewUrlGenerator.get_wipe_layout_url(layout_entry.id)
    data['confirm']['url']['cancel'] = ViewUrlGenerator.get_layout_edit_url(layout_entry.id)
    data['menu'] = ViewPrepareObjects.prepare_menu_for_html([])

    return res.get_template_data(request, 'presenter/confirm.html', data)
Exemple #25
0
def get_worker_edit(request, worker_id):
    """ Returns worker edit page to modify some workers properties """
    if request.method != 'GET':
        return res.get_only_get_allowed({})

    worker_entry = WorkerEntry.objects.filter(id=worker_id).first()
    if not worker_entry:
        return res.get_template_data(request, 'presenter/not_found.html', {})

    data = {}
    data['menu'] = ViewPrepareObjects.prepare_menu_for_html([])
    data['worker'] = worker_entry.as_object()
    data['worker']['url'] = {}
    data['worker']['url']['save'] = ViewUrlGenerator.get_worker_save_url(
        worker_id)
    data['worker']['url']['delete'] = ViewUrlGenerator.get_worker_delete_url(
        worker_id)

    return res.get_template_data(request, 'presenter/worker_edit.html', data)
Exemple #26
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 get_project_single_branch_links(request, project_id, branch_id):
    """ Display single branch links """
    if request.method != 'GET':
        return res.get_template_data(request, 'presenter/not_found.html', {})

    project_entry = GitProjectEntry.objects.filter(id=project_id).first()
    if project_entry is None:
        return res.get_template_data(request, 'presenter/not_found.html', {})

    branch_entry = GitBranchEntry.objects.filter(
        id=branch_id, project=project_entry).first()
    if branch_entry is None:
        return res.get_template_data(request, 'presenter/not_found.html', {})

    def_entries = BenchmarkDefinitionEntry.objects.all()
    worker_entries = WorkerEntry.objects.all()

    links = []

    for def_entry in def_entries:
        definition = {}
        definition['name'] = def_entry.name
        definition['id'] = def_entry.id
        definition['workers'] = []

        for worker_entry in worker_entries:
            worker = {}
            worker['name'] = worker_entry.name
            worker['uuid'] = worker_entry.uuid
            worker[
                'stacked_benchmarks'] = ViewUrlGenerator.get_benchmark_execution_stacked_url(
                    project_id, branch_id, def_entry.id, worker_entry.id, 1)
            definition['workers'].append(worker)

        links.append(definition)

    branch_names_and_orders = GitController.get_branch_names_and_order_values(
        project_entry)
    update_order_selection = []
    for name_and_order in branch_names_and_orders:
        obj = {}
        obj['name'] = name_and_order['name']
        obj['order'] = name_and_order['order']
        obj['current'] = name_and_order['id'] == branch_entry.id
        obj['url'] = {}
        obj['url']['update'] = ViewUrlGenerator.get_branch_update_order_url(
            branch_id, project_id, obj['order'])
        update_order_selection.append(obj)

    data = {}
    data['branch'] = {}
    data['branch']['name'] = branch_entry.name
    data['branch']['order'] = branch_entry.order
    data['branch']['url'] = {}
    data['branch']['url'][
        'single'] = ViewUrlGenerator.get_project_branch_single_url(
            project_id, branch_id)
    data['branch']['links'] = links
    data['branch']['update_order_selection'] = update_order_selection
    data['menu'] = ViewPrepareObjects.prepare_menu_for_html([])

    return res.get_template_data(request,
                                 'presenter/project_branch_links.html', data)
def get_benchmark_executions_of_branch(request):
    """ Returns the view for the executions of a branch """
    if request.method != 'GET':
        return res.get_template_data(request, 'presenter/not_found.html', {})

    layouts_obj = []
    layouts = BluesteelLayoutEntry.objects.all()

    for layout in layouts:
        layout_obj = {}
        layout_obj['id'] = layout.id
        layout_obj['name'] = layout.name
        layout_obj['projects'] = []

        projects = BluesteelProjectEntry.objects.filter(layout__id=layout.id)

        for project in projects:
            git_project = GitProjectEntry.objects.filter(
                id=project.git_project.id).first()

            if git_project is None:
                continue

            branch_names_and_orders = GitController.get_branch_names_and_order_values(
                git_project)
            executions_branch = []
            for name_and_order in branch_names_and_orders:
                obj = {}
                obj['name'] = name_and_order['name']
                obj['order'] = name_and_order['order']
                obj['url'] = {}
                obj['url'][
                    'executions_branch'] = ViewUrlGenerator.get_project_branch_single_links_url(
                        git_project.id, name_and_order['id'])
                executions_branch.append(obj)

            project_obj = {}
            project_obj['name'] = project.name
            project_obj['git_project_id'] = git_project.id
            project_obj['branches'] = executions_branch
            layout_obj['projects'].append(project_obj)

        layouts_obj.append(layout_obj)

    control1 = {}
    control1['name'] = ' Quick View'
    control1['link'] = ViewUrlGenerator.get_benchmark_executions_quick_url()
    control1['icon'] = 'fa fa-bar-chart'
    control1['onclick'] = 'window.location="{0}"'.format(control1['link'])

    control2 = {}
    control2['name'] = ' Per Branch'
    control2['link'] = ViewUrlGenerator.get_benchmark_executions_branches_url()
    control2['icon'] = 'fa fa-code-fork'
    control2['onclick'] = 'window.location="{0}"'.format(control2['link'])

    data = {}
    data['menu'] = ViewPrepareObjects.prepare_menu_for_html([])
    data['layouts'] = layouts_obj
    data['controls'] = []
    data['controls'].append(control1)
    data['controls'].append(control2)

    return res.get_template_data(
        request, 'presenter/benchmark_executions_branches.html', data)