From 4395b9da677c6cfa582d0c4e2d3a9e25173ade78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Ber=C3=A1nek?= Date: Sun, 6 Aug 2023 10:30:20 +0200 Subject: [PATCH 01/12] Move graph data to a separate module --- site/frontend/src/{pages/graphs/state.ts => graph/data.ts} | 0 site/frontend/src/pages/graphs/data-selector.vue | 2 +- site/frontend/src/pages/graphs/page.vue | 2 +- site/frontend/src/pages/graphs/plots.ts | 2 +- 4 files changed, 3 insertions(+), 3 deletions(-) rename site/frontend/src/{pages/graphs/state.ts => graph/data.ts} (100%) diff --git a/site/frontend/src/pages/graphs/state.ts b/site/frontend/src/graph/data.ts similarity index 100% rename from site/frontend/src/pages/graphs/state.ts rename to site/frontend/src/graph/data.ts diff --git a/site/frontend/src/pages/graphs/data-selector.vue b/site/frontend/src/pages/graphs/data-selector.vue index 9a11a8183..3f0032bb3 100644 --- a/site/frontend/src/pages/graphs/data-selector.vue +++ b/site/frontend/src/pages/graphs/data-selector.vue @@ -1,6 +1,6 @@ + diff --git a/site/frontend/src/pages/compare/compile/table/comparisons-table.vue b/site/frontend/src/pages/compare/compile/table/comparisons-table.vue index 980dbb771..02ee293db 100644 --- a/site/frontend/src/pages/compare/compile/table/comparisons-table.vue +++ b/site/frontend/src/pages/compare/compile/table/comparisons-table.vue @@ -7,6 +7,7 @@ import {CompileBenchmarkMap, CompileTestCase} from "../common"; import {computed} from "vue"; import {useExpandedStore} from "./expansion"; import BenchmarkDetail from "./benchmark-detail.vue"; +import {getDateInPast} from "./utils"; const props = defineProps<{ id: string; @@ -28,15 +29,8 @@ function graphLink( stat: string, comparison: TestCaseComparison ): string { - let date = new Date(commit.date); - // Move to `30 days ago` to display history of the test case - date.setUTCDate(date.getUTCDate() - 30); - let year = date.getUTCFullYear(); - let month = (date.getUTCMonth() + 1).toString().padStart(2, "0"); - let day = date.getUTCDate().toString().padStart(2, "0"); - let start = `${year}-${month}-${day}`; - - let end = commit.commit; + const start = getDateInPast(commit); + const end = commit.commit; const {benchmark, profile, scenario} = comparison.testCase; return `/index.html?start=${start}&end=${end}&benchmark=${benchmark}&profile=${profile}&scenario=${scenario}&stat=${stat}`; } @@ -202,6 +196,8 @@ const {toggleExpanded, isExpanded} = useExpandedStore(); diff --git a/site/frontend/src/pages/compare/compile/table/utils.ts b/site/frontend/src/pages/compare/compile/table/utils.ts new file mode 100644 index 000000000..ca825b288 --- /dev/null +++ b/site/frontend/src/pages/compare/compile/table/utils.ts @@ -0,0 +1,14 @@ +import {ArtifactDescription} from "../../types"; + +/** + * Returns a date in the past for which we want to display a historical chart. + */ +export function getDateInPast(artifact: ArtifactDescription): string { + const date = new Date(artifact.date); + // Move to `30 days ago` to display history of the test case + date.setUTCDate(date.getUTCDate() - 30); + const year = date.getUTCFullYear(); + const month = (date.getUTCMonth() + 1).toString().padStart(2, "0"); + const day = date.getUTCDate().toString().padStart(2, "0"); + return `${year}-${month}-${day}`; +} diff --git a/site/frontend/templates/pages/compare.html b/site/frontend/templates/pages/compare.html index 42238eace..1410d07c2 100644 --- a/site/frontend/templates/pages/compare.html +++ b/site/frontend/templates/pages/compare.html @@ -1,5 +1,7 @@ {% extends "layout.html" %} {% block head %} + + +