Skip to content

Commit 95cdac6

Browse files
committed
Move graph API call to a separate module
1 parent d385dfa commit 95cdac6

File tree

2 files changed

+21
-14
lines changed

2 files changed

+21
-14
lines changed

site/frontend/src/graph/api.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import {GraphData, GraphsSelector} from "./data";
2+
import {getJson} from "../utils/requests";
3+
import {GRAPH_DATA_URL} from "../urls";
4+
5+
export async function loadGraphs(selector: GraphsSelector): Promise<GraphData> {
6+
const params = {
7+
start: selector.start,
8+
end: selector.end,
9+
kind: selector.kind as string,
10+
stat: selector.stat,
11+
benchmark: selector.benchmark,
12+
scenario: selector.scenario,
13+
profile: selector.profile,
14+
};
15+
return await getJson<GraphData>(GRAPH_DATA_URL, params);
16+
}

site/frontend/src/pages/graphs/page.vue

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,16 @@
22
import {nextTick, Ref, ref} from "vue";
33
import {withLoading} from "../../utils/loading";
44
import {GraphData, GraphKind, GraphsSelector} from "../../graph/data";
5-
import {GRAPH_DATA_URL} from "../../urls";
65
import DataSelector, {SelectionParams} from "./data-selector.vue";
76
import {
87
createUrlWithAppendedParams,
98
getUrlParams,
109
navigateToUrlParams,
1110
} from "../../utils/navigation";
1211
import {renderPlots} from "./plots";
13-
import {getJson} from "../../utils/requests";
1412
import {BenchmarkInfo, loadBenchmarkInfo} from "../../api";
1513
import AsOf from "../../components/as-of.vue";
14+
import {loadGraphs} from "../../graph/api";
1615
1716
function loadSelectorFromUrl(urlParams: Dict<string>): GraphsSelector {
1817
const start = urlParams["start"] ?? "";
@@ -60,18 +59,10 @@ function hasSpecificSelection(selector: GraphsSelector): boolean {
6059
}
6160
6261
async function loadGraphData(selector: GraphsSelector, loading: Ref<boolean>) {
63-
const graphData: GraphData = await withLoading(loading, async () => {
64-
const params = {
65-
start: selector.start,
66-
end: selector.end,
67-
kind: selector.kind as string,
68-
stat: selector.stat,
69-
benchmark: selector.benchmark,
70-
scenario: selector.scenario,
71-
profile: selector.profile,
72-
};
73-
return await getJson<GraphData>(GRAPH_DATA_URL, params);
74-
});
62+
const graphData: GraphData = await withLoading(
63+
loading,
64+
async () => await loadGraphs(selector)
65+
);
7566
7667
// Wait for the UI to be updated, which also resets the plot HTML elements.
7768
// Then draw the plots.

0 commit comments

Comments
 (0)