Skip to content

Commit 917696e

Browse files
committed
Refactor detailed-query.ts
1 parent 05ef749 commit 917696e

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

site/frontend/src/pages/detailed-query.ts

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,8 @@ function populate_data(data, state: Selector) {
5050
txt += `<br><a href="${self_href}">query info for just this commit</a>`;
5151
}
5252
document.querySelector("#title").innerHTML = txt;
53-
let dl_url = (commit, bench, run) => {
54-
return `/perf/download-raw-self-profile?commit=${commit}&benchmark=${bench}&scenario=${run}`;
55-
};
5653
let dl_link = (commit, bench, run) => {
57-
let url = dl_url(commit, bench, run);
54+
let url = `/perf/download-raw-self-profile?commit=${commit}&benchmark=${bench}&scenario=${run}`;
5855
return `<a href="${url}">raw</a>`;
5956
};
6057
let processed_url = (commit, bench, run, ty) => {
@@ -297,19 +294,19 @@ interface Selector {
297294
commit: string;
298295
base_commit: string | null;
299296
benchmark: string;
300-
// #[serde(alias = "run_name")]
301297
scenario: string;
302298
sort_idx: string | number;
303299
}
304300

305301
async function loadData() {
306302
const params = getUrlParams();
303+
const {commit, base_commit, benchmark, scenario, sort_idx} = params;
307304
const selector: Selector = {
308-
commit: params["commit"],
309-
base_commit: params["base_commit"] ?? null,
310-
benchmark: params["benchmark"],
311-
scenario: params["scenario"],
312-
sort_idx: params["sort_idx"] ?? "-2"
305+
commit,
306+
base_commit: base_commit ?? null,
307+
benchmark,
308+
scenario,
309+
sort_idx: sort_idx ?? "-2"
313310
};
314311

315312
const response = await postMsgpack(SELF_PROFILE_DATA_URL, selector);

site/frontend/src/utils/navigation.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,11 @@ export function createUrlWithParams(params: Dict<any>): URL {
66
const originalUrl = window.location.toString();
77
const url = new URL(originalUrl);
88
for (const [key, value] of Object.entries(params)) {
9-
if (value !== null && value !== undefined && value !== "") {
10-
url.searchParams.set(key, value.toString());
9+
if (value !== null && value !== undefined) {
10+
const stringified = value.toString();
11+
if (stringified !== "") {
12+
url.searchParams.set(key, stringified);
13+
}
1114
}
1215
}
1316
return url;

0 commit comments

Comments
 (0)