From 476fd84d2d0fa2b5667650fa12353261d0f358f5 Mon Sep 17 00:00:00 2001 From: Joscha Date: Tue, 15 Aug 2023 00:36:40 +0200 Subject: [PATCH] Display test graph --- ...9bd72a8341511486d2c0e6612f4eed2b4b95.json} | 4 +- ...991a7a27708a69fbf89b43231927fc85519f.json} | 4 +- migrations/20230805101911_commits.sql | 2 +- scripts/graph.ts | 48 ++++++++++++++++--- src/server/web/pages/graph.rs | 8 ++-- templates/pages/graph.html | 1 + 6 files changed, 53 insertions(+), 14 deletions(-) rename .sqlx/{query-4e2f2b25a13b3728db01b7c218e7250441098c60725c081215489bd2ad944fe0.json => query-9f70a2d2932837e4fcd927bcc56d9bd72a8341511486d2c0e6612f4eed2b4b95.json} (75%) rename .sqlx/{query-039485fead98beb9d088c5bb35679f2ab0409e7e6b51607869ec30ef35240504.json => query-ac7a2e727b2ff96ae6d6be2c05e9991a7a27708a69fbf89b43231927fc85519f.json} (73%) diff --git a/.sqlx/query-4e2f2b25a13b3728db01b7c218e7250441098c60725c081215489bd2ad944fe0.json b/.sqlx/query-9f70a2d2932837e4fcd927bcc56d9bd72a8341511486d2c0e6612f4eed2b4b95.json similarity index 75% rename from .sqlx/query-4e2f2b25a13b3728db01b7c218e7250441098c60725c081215489bd2ad944fe0.json rename to .sqlx/query-9f70a2d2932837e4fcd927bcc56d9bd72a8341511486d2c0e6612f4eed2b4b95.json index 1d961bb..8e735d2 100644 --- a/.sqlx/query-4e2f2b25a13b3728db01b7c218e7250441098c60725c081215489bd2ad944fe0.json +++ b/.sqlx/query-9f70a2d2932837e4fcd927bcc56d9bd72a8341511486d2c0e6612f4eed2b4b95.json @@ -1,6 +1,6 @@ { "db_name": "SQLite", - "query": "WITH measurements AS ( SELECT hash, value, MAX(start) FROM runs JOIN run_measurements USING (id) WHERE name = ? GROUP BY hash ) SELECT value FROM commits LEFT JOIN measurements USING (hash) ORDER BY committer_date ASC, hash ASC ", + "query": "WITH measurements AS ( SELECT hash, value, MAX(start) FROM runs JOIN run_measurements USING (id) WHERE name = ? GROUP BY hash ) SELECT value FROM commits LEFT JOIN measurements USING (hash) ORDER BY unixepoch(committer_date) ASC, hash ASC ", "describe": { "columns": [ { @@ -16,5 +16,5 @@ true ] }, - "hash": "4e2f2b25a13b3728db01b7c218e7250441098c60725c081215489bd2ad944fe0" + "hash": "9f70a2d2932837e4fcd927bcc56d9bd72a8341511486d2c0e6612f4eed2b4b95" } diff --git a/.sqlx/query-039485fead98beb9d088c5bb35679f2ab0409e7e6b51607869ec30ef35240504.json b/.sqlx/query-ac7a2e727b2ff96ae6d6be2c05e9991a7a27708a69fbf89b43231927fc85519f.json similarity index 73% rename from .sqlx/query-039485fead98beb9d088c5bb35679f2ab0409e7e6b51607869ec30ef35240504.json rename to .sqlx/query-ac7a2e727b2ff96ae6d6be2c05e9991a7a27708a69fbf89b43231927fc85519f.json index 19b79db..194280e 100644 --- a/.sqlx/query-039485fead98beb9d088c5bb35679f2ab0409e7e6b51607869ec30ef35240504.json +++ b/.sqlx/query-ac7a2e727b2ff96ae6d6be2c05e9991a7a27708a69fbf89b43231927fc85519f.json @@ -1,6 +1,6 @@ { "db_name": "SQLite", - "query": "SELECT hash, committer_date AS \"committer_date: time::OffsetDateTime\" FROM commits ORDER BY committer_date ASC, hash ASC ", + "query": "SELECT hash, committer_date AS \"committer_date: time::OffsetDateTime\" FROM commits ORDER BY unixepoch(committer_date) ASC, hash ASC ", "describe": { "columns": [ { @@ -22,5 +22,5 @@ false ] }, - "hash": "039485fead98beb9d088c5bb35679f2ab0409e7e6b51607869ec30ef35240504" + "hash": "ac7a2e727b2ff96ae6d6be2c05e9991a7a27708a69fbf89b43231927fc85519f" } diff --git a/migrations/20230805101911_commits.sql b/migrations/20230805101911_commits.sql index fbd2f62..71c3f50 100644 --- a/migrations/20230805101911_commits.sql +++ b/migrations/20230805101911_commits.sql @@ -27,7 +27,7 @@ CREATE TABLE refs ( ) STRICT; CREATE INDEX idx_commits_committer_date_hash -ON commits (committer_date, hash); +ON commits (unixepoch(committer_date), hash); CREATE INDEX idx_commit_links_parent_child ON commit_links (parent, child); diff --git a/scripts/graph.ts b/scripts/graph.ts index 3731d5b..e6a6006 100644 --- a/scripts/graph.ts +++ b/scripts/graph.ts @@ -1,7 +1,43 @@ -import uPlot from "./uPlot"; +import uPlot from "./uPlot.js"; -let plot = new uPlot({ - width: 300, - height: 200, - series: [], -}); +interface GraphData { + hashes: string[]; + times: number[]; + metrics: { [key: string]: (number | null)[]; }; +} + +let opts = { + title: "HEHE", + width: 600, + height: 400, + series: [ + {}, + { + label: "wall-clock/build", + spanGaps: true, + stroke: "blue", + width: 1, + } + ], +}; + +let plot = new uPlot(opts, [], document.body); + +fetch("data?metric=wall-clock/build") + .then(r => r.json() as Promise) + .then(data => { + console.log(data); + plot.setData([ + data.times, + data.metrics["wall-clock/build"]!, + ]); + }); + +// function display(metrics: string[]) { +// let url = "data" + new URLSearchParams(metrics.map(m => ["metric", m])); +// fetch(url) +// .then(r => r.json() as Promise) +// .then(data => { + +// }) +// } diff --git a/src/server/web/pages/graph.rs b/src/server/web/pages/graph.rs index 9293ffb..9d20604 100644 --- a/src/server/web/pages/graph.rs +++ b/src/server/web/pages/graph.rs @@ -11,7 +11,7 @@ use crate::{ server::web::{ base::{Base, Link, Tab}, paths::{PathGraph, PathGraphData}, - r#static::GRAPH_JS, + r#static::{GRAPH_JS, UPLOT_CSS}, }, somehow, }; @@ -19,6 +19,7 @@ use crate::{ #[derive(Template)] #[template(path = "pages/graph.html")] struct Page { + link_uplot_css: Link, link_graph_js: Link, base: Base, } @@ -29,6 +30,7 @@ pub async fn get_graph( ) -> somehow::Result { let base = Base::new(config, Tab::Graph); Ok(Page { + link_uplot_css: base.link(UPLOT_CSS), link_graph_js: base.link(GRAPH_JS), base, }) @@ -60,7 +62,7 @@ pub async fn get_graph_data( hash, \ committer_date AS \"committer_date: time::OffsetDateTime\" \ FROM commits \ - ORDER BY committer_date ASC, hash ASC \ + ORDER BY unixepoch(committer_date) ASC, hash ASC \ " ) .fetch_all(&mut *conn) @@ -88,7 +90,7 @@ pub async fn get_graph_data( SELECT value \ FROM commits \ LEFT JOIN measurements USING (hash) \ - ORDER BY committer_date ASC, hash ASC \ + ORDER BY unixepoch(committer_date) ASC, hash ASC \ ", metric, ) diff --git a/templates/pages/graph.html b/templates/pages/graph.html index 9c92d78..ac2dde8 100644 --- a/templates/pages/graph.html +++ b/templates/pages/graph.html @@ -3,6 +3,7 @@ {% block title %}graph{% endblock %} {% block head %} + {% endblock %}