Port commit page
This commit is contained in:
parent
db0234b750
commit
373b3168f1
7 changed files with 111 additions and 19 deletions
26
.sqlx/query-b43ea10c6fd75dfe251c3dc3001649a13b9893722b23c2bbcec1f015e57b5613.json
generated
Normal file
26
.sqlx/query-b43ea10c6fd75dfe251c3dc3001649a13b9893722b23c2bbcec1f015e57b5613.json
generated
Normal file
|
|
@ -0,0 +1,26 @@
|
||||||
|
{
|
||||||
|
"db_name": "SQLite",
|
||||||
|
"query": "SELECT id, start AS \"start: time::OffsetDateTime\" FROM runs WHERE hash = ? ",
|
||||||
|
"describe": {
|
||||||
|
"columns": [
|
||||||
|
{
|
||||||
|
"name": "id",
|
||||||
|
"ordinal": 0,
|
||||||
|
"type_info": "Text"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "start: time::OffsetDateTime",
|
||||||
|
"ordinal": 1,
|
||||||
|
"type_info": "Text"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"parameters": {
|
||||||
|
"Right": 1
|
||||||
|
},
|
||||||
|
"nullable": [
|
||||||
|
false,
|
||||||
|
false
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"hash": "b43ea10c6fd75dfe251c3dc3001649a13b9893722b23c2bbcec1f015e57b5613"
|
||||||
|
}
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
mod admin;
|
mod admin;
|
||||||
mod api;
|
mod api;
|
||||||
mod base;
|
mod base;
|
||||||
mod commit;
|
|
||||||
mod index;
|
mod index;
|
||||||
mod link;
|
mod link;
|
||||||
mod pages;
|
mod pages;
|
||||||
|
|
@ -21,8 +20,8 @@ use self::{
|
||||||
get_api_worker_bench_repo_by_hash_tree_tar_gz, get_api_worker_repo_by_hash_tree_tar_gz,
|
get_api_worker_bench_repo_by_hash_tree_tar_gz, get_api_worker_repo_by_hash_tree_tar_gz,
|
||||||
post_api_worker_status,
|
post_api_worker_status,
|
||||||
},
|
},
|
||||||
commit::get_commit_by_hash,
|
|
||||||
index::get_index,
|
index::get_index,
|
||||||
|
pages::commit::get_commit_by_hash,
|
||||||
queue::{get_queue, get_queue_inner},
|
queue::{get_queue, get_queue_inner},
|
||||||
worker::get_worker_by_name,
|
worker::get_worker_by_name,
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,14 @@ use serde::Deserialize;
|
||||||
use sqlx::SqlitePool;
|
use sqlx::SqlitePool;
|
||||||
use time::OffsetDateTime;
|
use time::OffsetDateTime;
|
||||||
|
|
||||||
use crate::{config::Config, server::web::paths::PathAdminQueueAdd, somehow};
|
use crate::{
|
||||||
|
config::Config,
|
||||||
|
server::web::{
|
||||||
|
base::{Base, Tab},
|
||||||
|
paths::{PathAdminQueueAdd, PathQueue},
|
||||||
|
},
|
||||||
|
somehow,
|
||||||
|
};
|
||||||
|
|
||||||
#[derive(Deserialize)]
|
#[derive(Deserialize)]
|
||||||
pub struct FormAdminQueueAdd {
|
pub struct FormAdminQueueAdd {
|
||||||
|
|
@ -36,6 +43,6 @@ pub async fn post_admin_queue_add(
|
||||||
.execute(&db)
|
.execute(&db)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
// TODO Replace with typed link
|
let link = Base::new(config, Tab::None).link(PathQueue {});
|
||||||
Ok(Redirect::to(&format!("{}queue/", config.web_base)))
|
Ok(Redirect::to(&format!("{link}")))
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
use askama::Template;
|
use askama::Template;
|
||||||
|
use time::OffsetDateTime;
|
||||||
|
|
||||||
use crate::server::util;
|
use crate::server::util;
|
||||||
|
|
||||||
|
|
@ -51,6 +52,25 @@ impl LinkRunShort {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Template)]
|
||||||
|
#[template(
|
||||||
|
ext = "html",
|
||||||
|
source = "<a href=\"{{ link }}\">Run from {{ date }}</a>"
|
||||||
|
)]
|
||||||
|
pub struct LinkRunDate {
|
||||||
|
link: Link,
|
||||||
|
date: String, // TODO base.date(...)?
|
||||||
|
}
|
||||||
|
|
||||||
|
impl LinkRunDate {
|
||||||
|
pub fn new(base: &Base, id: String, start: OffsetDateTime) -> Self {
|
||||||
|
Self {
|
||||||
|
link: base.link(PathRunById { id }),
|
||||||
|
date: util::format_time(start),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Template)]
|
#[derive(Template)]
|
||||||
#[template(ext = "html", source = "<a href=\"{{ link }}\">{{ name }}</a>")]
|
#[template(ext = "html", source = "<a href=\"{{ link }}\">{{ name }}</a>")]
|
||||||
pub struct LinkWorker {
|
pub struct LinkWorker {
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
pub mod commit;
|
||||||
|
|
@ -7,19 +7,26 @@ use axum::{
|
||||||
use futures::TryStreamExt;
|
use futures::TryStreamExt;
|
||||||
use sqlx::SqlitePool;
|
use sqlx::SqlitePool;
|
||||||
|
|
||||||
use crate::{config::Config, server::util, somehow};
|
use crate::{
|
||||||
|
config::Config,
|
||||||
use super::{
|
server::{
|
||||||
base::{Base, Link, Tab},
|
util,
|
||||||
link::LinkCommit,
|
web::{
|
||||||
paths::{PathAdminQueueAdd, PathCommitByHash},
|
base::{Base, Link, Tab},
|
||||||
|
link::{LinkCommit, LinkRunDate},
|
||||||
|
paths::{PathAdminQueueAdd, PathCommitByHash},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
somehow,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Template)]
|
#[derive(Template)]
|
||||||
#[template(path = "commit.html")]
|
#[template(path = "pages/commit.html")]
|
||||||
struct CommitTemplate {
|
struct Page {
|
||||||
link_admin_queue_add: Link,
|
link_admin_queue_add: Link,
|
||||||
base: Base,
|
base: Base,
|
||||||
|
|
||||||
|
summary: String,
|
||||||
hash: String,
|
hash: String,
|
||||||
author: String,
|
author: String,
|
||||||
author_date: String,
|
author_date: String,
|
||||||
|
|
@ -27,9 +34,9 @@ struct CommitTemplate {
|
||||||
commit_date: String,
|
commit_date: String,
|
||||||
parents: Vec<LinkCommit>,
|
parents: Vec<LinkCommit>,
|
||||||
children: Vec<LinkCommit>,
|
children: Vec<LinkCommit>,
|
||||||
summary: String,
|
|
||||||
message: String,
|
message: String,
|
||||||
reachable: i64,
|
reachable: i64,
|
||||||
|
runs: Vec<LinkRunDate>,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn get_commit_by_hash(
|
pub async fn get_commit_by_hash(
|
||||||
|
|
@ -88,9 +95,25 @@ pub async fn get_commit_by_hash(
|
||||||
.try_collect::<Vec<_>>()
|
.try_collect::<Vec<_>>()
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
Ok(CommitTemplate {
|
let runs = sqlx::query!(
|
||||||
|
"\
|
||||||
|
SELECT \
|
||||||
|
id, \
|
||||||
|
start AS \"start: time::OffsetDateTime\" \
|
||||||
|
FROM runs WHERE hash = ? \
|
||||||
|
",
|
||||||
|
path.hash
|
||||||
|
)
|
||||||
|
.fetch(&db)
|
||||||
|
.map_ok(|r| LinkRunDate::new(&base, r.id, r.start))
|
||||||
|
.try_collect::<Vec<_>>()
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
Ok(Page {
|
||||||
link_admin_queue_add: base.link(PathAdminQueueAdd {}),
|
link_admin_queue_add: base.link(PathAdminQueueAdd {}),
|
||||||
base,
|
base,
|
||||||
|
|
||||||
|
summary: util::format_commit_summary(&commit.message),
|
||||||
hash: commit.hash,
|
hash: commit.hash,
|
||||||
author: commit.author,
|
author: commit.author,
|
||||||
author_date: util::format_time(commit.author_date),
|
author_date: util::format_time(commit.author_date),
|
||||||
|
|
@ -98,9 +121,9 @@ pub async fn get_commit_by_hash(
|
||||||
commit_date: util::format_time(commit.committer_date),
|
commit_date: util::format_time(commit.committer_date),
|
||||||
parents,
|
parents,
|
||||||
children,
|
children,
|
||||||
summary: util::format_commit_summary(&commit.message),
|
|
||||||
message: commit.message.trim_end().to_string(),
|
message: commit.message.trim_end().to_string(),
|
||||||
reachable: commit.reachable,
|
reachable: commit.reachable,
|
||||||
|
runs,
|
||||||
}
|
}
|
||||||
.into_response())
|
.into_response())
|
||||||
}
|
}
|
||||||
|
|
@ -4,9 +4,11 @@
|
||||||
{% block title %}{{ summary }}{% endblock %}
|
{% block title %}{{ summary }}{% endblock %}
|
||||||
|
|
||||||
{% block body %}
|
{% block body %}
|
||||||
|
|
||||||
<h2>Commit</h2>
|
<h2>Commit</h2>
|
||||||
<div class="commit">
|
|
||||||
<span class="hash">commit {{ hash }}</span>
|
<div>
|
||||||
|
<span>commit {{ hash }}</span>
|
||||||
<dl>
|
<dl>
|
||||||
<dt>Author:</dt>
|
<dt>Author:</dt>
|
||||||
<dd>{{ author }}</dd>
|
<dd>{{ author }}</dd>
|
||||||
|
|
@ -34,9 +36,23 @@
|
||||||
title="{% call util::commit_title(reachable) %}">{{ message }}</pre>
|
title="{% call util::commit_title(reachable) %}">{{ message }}</pre>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<h2>Runs</h2>
|
||||||
|
|
||||||
|
{% if runs.is_empty() %}
|
||||||
|
There aren't any runs yet.
|
||||||
|
{% else %}
|
||||||
|
<ul>
|
||||||
|
{% for run in runs %}
|
||||||
|
<li>{{ run|safe }}</li>
|
||||||
|
{% endfor %}
|
||||||
|
</ul>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
<form method="post" action="{{ link_admin_queue_add }}">
|
<form method="post" action="{{ link_admin_queue_add }}">
|
||||||
<input type="hidden" name="hash" value="{{ hash }}">
|
<input type="hidden" name="hash" value="{{ hash }}">
|
||||||
<label>Priority: <input type="number" name="priority" value="0" min="-2147483648" max="2147483647"></label>
|
|
||||||
<button>Add to queue</button>
|
<button>Add to queue</button>
|
||||||
|
with a <label for="priority">priority</label> of
|
||||||
|
<input id="priority" name="priority" type="number" value="10" min="-2147483648" max="2147483647">.
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue