Skip to content

Commit

Permalink
fixed non-working links
Browse files Browse the repository at this point in the history
  • Loading branch information
YedilSerzhan committed Jul 1, 2022
1 parent dd083c9 commit a4d4e07
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 18 deletions.
7 changes: 2 additions & 5 deletions rest_api/benchmarks/views.py
Expand Up @@ -150,7 +150,7 @@ def pgbench_benchmark_machines_view(request):


def machine_history_view(request, machine):

machine_id = machine
machine_history = Machine.objects.raw("select machine_id, alias, machines_machine.description, machines_machine.add_time, machine_type, username, email, url, dist_name, kernel_name, kernel_release, kernel_version, release, codename, compiler, name, url, min(run_id) as run_id, count(run_id), postgres_info_id, mounts, systems_hardwareinfo.sysctl, runs_runinfo.hardware_info_id, pgbench_benchmark_id, scale, duration, read_only, clients, cpu_brand, hz, cpu_cores, total_memory, total_swap from runs_gitrepo, benchmarks_pgbenchbenchmark, benchmarks_pgbenchresult, runs_runinfo, runs_branch, machines_machine, auth_user, systems_compiler, systems_oskernelversion, systems_kernel, systems_osdistributor, systems_osversion, systems_hardwareinfo where benchmarks_pgbenchbenchmark.pgbench_benchmark_id = benchmarks_pgbenchresult.benchmark_config_id and runs_branch.git_repo_id = runs_gitrepo.git_repo_id and benchmarks_pgbenchresult.run_id_id = runs_runinfo.run_id and runs_runinfo.git_branch_id = runs_branch.branch_id and systems_hardwareinfo.hardware_info_id = runs_runinfo.hardware_info_id and runs_runinfo.machine_id_id = machines_machine.machine_id and runs_runinfo.compiler_id = systems_compiler.compiler_id and machines_machine.owner_id_id = auth_user.id and runs_runinfo.os_version_id_id = systems_osversion.os_version_id and runs_runinfo.os_kernel_version_id_id = systems_oskernelversion.os_kernel_version_id and systems_oskernelversion.kernel_id_id = systems_kernel.kernel_id and systems_osversion.dist_id_id = systems_osdistributor.os_distributor_id and machine_id_id = %s group by url, dist_name, machines_machine.add_time, kernel_name, kernel_release, kernel_version, release, codename, mounts, systems_hardwareinfo.sysctl, compiler, name, postgres_info_id, runs_runinfo.hardware_info_id, pgbench_benchmark_id, scale, duration, read_only, clients, machine_id, alias, machines_machine.description, machine_type, username, email, cpu_brand, hz, cpu_cores, total_memory, total_swap order by run_id desc;", [machine])

machine_history_list = []
Expand Down Expand Up @@ -211,17 +211,14 @@ def comapre_call_back(item, compared_str, item_name):
'sysctl': sysctl_string,
'run_id': history['run_id']
})
configurationListContent = ''
for key, value in benchmarks.items():
configurationListContent += '<div><a href="/trend?id=${id}&config=${value}"> ${name}</a></div>' % ()

return render(request, 'machines/machine_history.html', {'machine_history_list': machine_history_list,
'reports': reports,
'benchmarks': benchmarks,
'branches': branches,
'sysctl_data': sysctl_data,
'compiler_data': compiler_data,
'os_data': os_data
'os_data': os_data,
})


Expand Down
18 changes: 12 additions & 6 deletions rest_api/machines/views.py
Expand Up @@ -10,12 +10,18 @@


def index(request):
machines = Machine.objects.all().values('machine_id', 'alias', 'machine_type', 'add_time', 'description',
'approved', 'owner_id__username')
for m in machines:
m['next_url'] = '/benchmark/history/' + str(m['machine_id']) + '/'
context = {'machines': machines}
return render(request, 'machines/index.html', context)
def get_latest(machine):
run_info = RunInfo.objects.filter(machine_id=machine['machine_id']).order_by('-add_time')[:3].values('run_id')
return [item['run_id'] for item in run_info]

machines = Machine.objects.all().values('machine_id', 'alias', 'machine_type', 'add_time', 'description', 'approved', 'owner_id__username')
machines_list = list(machines)

for machine in machines_list:
machine['latest'] = get_latest(machine)
machine['next_url'] = '/benchmark/history/' + str(machine['machine_id']) + '/'

return render(request, 'machines/index.html', {'machines': machines_list})

@login_required
def add_machine_view(request):
Expand Down
1 change: 0 additions & 1 deletion rest_api/pages/views.py
Expand Up @@ -9,5 +9,4 @@ def index(request):
for row in overview:
for column in overview.columns:
overview_json[column] = getattr(row, column)
# print(overview_json)
return render(request, 'pages/index.html', {'result': overview_json})
2 changes: 1 addition & 1 deletion rest_api/templates/benchmarks/trend.html
Expand Up @@ -797,7 +797,7 @@
document.querySelector('#value_duration').innerHTML = duration;
document.querySelector('#value_read_write').innerHTML = read_only;

document.querySelector('#link__machine').href = '/machine?id=' + machine_id;
document.querySelector('#link__machine').href = '/benchmark/history/' + machine_id + '/';
document.querySelector('#download__json').onclick = () => downloadJSON(response);


Expand Down
4 changes: 3 additions & 1 deletion rest_api/templates/machines/index.html
Expand Up @@ -32,7 +32,9 @@
<td>{{ machine.add_time }}</td>
<td>
{% if machine.latest %}
<a href="">latest run</a>
{% for run in machine.latest %}
<a href="/run/{{run}}/">{{run}}</a>
{% endfor %}
{% endif %}
</td>
</tr>
Expand Down
2 changes: 1 addition & 1 deletion rest_api/templates/machines/machine_history.html
Expand Up @@ -34,7 +34,7 @@

<div id=machine__configurations__list>
{% for value, name in benchmarks.items %}
<div><a href="{{'/trend?id='|add:machine_history_list.0.machine_id|add:'&config='|add:value}}">{{name}}</a></div>
<div><a href="/benchmark/pgbench_trends/{{machine_history_list.0.machine_id}}/{{value}}/">{{name}}</a></div>
{% endfor %}
</div>

Expand Down
2 changes: 1 addition & 1 deletion rest_api/templates/pages/index.html
Expand Up @@ -42,7 +42,7 @@
</div>

<div class="home__item">
Last run <a id="value_last_run_trends" href="{{ '/trend?id='| add:result.last_machine_id | add:result.machine_id_id }}">trends</a>
Last run <a id="value_last_run_trends" href="/benchmark/pgbench_trends/{{result.last_machine_id}}/{{result.pgbench_benchmark_id}}/">trends</a>
<br>
Scale <span id="value_scale" class="text-color">{{ result.scale }}</span>, duration <span id="value_duration" class="text-color">{{ result.duration }}</span>, clients <span id="value_clients" class="text-color">{{ result.clients }}</span>,
<span id="value_read_only" class="text-color">
Expand Down
4 changes: 2 additions & 2 deletions rest_api/templates/runs/index.html
Expand Up @@ -12,8 +12,8 @@
<div>Branch : <span id="value_branch">{{run.git_branch_id__name}}</span></div>
<div>Uploaded : <span id="value_time">{{run.add_time}}</span></div>
<div>Owner : <span id="value_owner">{{run.machine_id__owner_id__username}}</span></div>
<div>Commit : <a id="link_commit"><span id="value_commit">https://git.postgresql.org/gitweb/?p=postgresql.git;a=commit;h={{run.git_commit}}</span></a></div>
<div>Repository : <a id="link_repo"><span id="value_repository">{{run.git_branch_id__git_repo_id__url}}</span></a></div>
<div>Commit : <a id="link_commit" href="https://git.postgresql.org/gitweb/?p=postgresql.git;a=commit;h={{run.git_commit}}"><span id="value_commit">https://git.postgresql.org/gitweb/?p=postgresql.git;a=commit;h={{run.git_commit}}</span></a></div>
<div>Repository : <a id="link_repo" href="{{run.git_branch_id__git_repo_id__url}}"><span id="value_repository">{{run.git_branch_id__git_repo_id__url}}</span></a></div>
</div>

<div class="card">
Expand Down

0 comments on commit a4d4e07

Please sign in to comment.