diff --git a/.sqlx/query-d9514b13cf1c28edb9d868a25d23e39d60676116f7ca6488032f8cfbf274f320.json b/.sqlx/query-d9514b13cf1c28edb9d868a25d23e39d60676116f7ca6488032f8cfbf274f320.json new file mode 100644 index 0000000..acef35c --- /dev/null +++ b/.sqlx/query-d9514b13cf1c28edb9d868a25d23e39d60676116f7ca6488032f8cfbf274f320.json @@ -0,0 +1,50 @@ +{ + "db_name": "SQLite", + "query": "SELECT id, hash, date AS \"date: time::OffsetDateTime\", priority, message, reachable FROM queue JOIN commits USING (hash) WHERE id = ? ", + "describe": { + "columns": [ + { + "name": "id", + "ordinal": 0, + "type_info": "Text" + }, + { + "name": "hash", + "ordinal": 1, + "type_info": "Text" + }, + { + "name": "date: time::OffsetDateTime", + "ordinal": 2, + "type_info": "Text" + }, + { + "name": "priority", + "ordinal": 3, + "type_info": "Int64" + }, + { + "name": "message", + "ordinal": 4, + "type_info": "Text" + }, + { + "name": "reachable", + "ordinal": 5, + "type_info": "Int64" + } + ], + "parameters": { + "Right": 1 + }, + "nullable": [ + false, + false, + false, + false, + false, + false + ] + }, + "hash": "d9514b13cf1c28edb9d868a25d23e39d60676116f7ca6488032f8cfbf274f320" +} diff --git a/src/web.rs b/src/web.rs index 77e729d..465a4e0 100644 --- a/src/web.rs +++ b/src/web.rs @@ -2,6 +2,7 @@ mod commit; mod commit_hash; mod index; mod queue; +mod queue_id; mod r#static; use axum::{routing::get, Router, Server}; @@ -45,6 +46,7 @@ pub async fn run(state: AppState) -> somehow::Result<()> { .route("/commit/:hash", get(commit_hash::get)) .route("/queue/", get(queue::get)) .route("/queue/table", get(queue::get_table)) + .route("/queue/:id", get(queue_id::get)) .fallback(get(r#static::static_handler)) .with_state(state.clone()); diff --git a/src/web/queue_id.rs b/src/web/queue_id.rs new file mode 100644 index 0000000..77ced5d --- /dev/null +++ b/src/web/queue_id.rs @@ -0,0 +1,65 @@ +use askama::Template; +use axum::{ + extract::{Path, State}, + http::StatusCode, + response::{IntoResponse, Response}, +}; +use sqlx::SqlitePool; + +use crate::{config::Config, somehow, util}; + +use super::{Base, Tab}; + +#[derive(Template)] +#[template(path = "queue_id.html")] +struct QueueIdTemplate { + base: Base, + // Task + id: String, + hash: String, + date: String, + priority: i64, + // Commit + summary: String, + short: String, + reachable: i64, +} + +pub async fn get( + Path(id): Path, + State(config): State<&'static Config>, + State(db): State, +) -> somehow::Result { + let Some(task) = sqlx::query!( + "\ + SELECT \ + id, \ + hash, \ + date AS \"date: time::OffsetDateTime\", \ + priority, \ + message, \ + reachable \ + FROM queue \ + JOIN commits USING (hash) \ + WHERE id = ? \ + ", + id + ) + .fetch_optional(&db) + .await? + else { + return Ok(StatusCode::NOT_FOUND.into_response()); + }; + + Ok(QueueIdTemplate { + base: Base::new(config, Tab::Queue), + date: util::format_time(task.date), + id: task.id, + priority: task.priority, + summary: util::format_commit_summary(&task.message), + short: util::format_commit_short(&task.hash, &task.message), + hash: task.hash, + reachable: task.reachable, + } + .into_response()) +} diff --git a/static/base.css b/static/base.css index d72b62e..41e14b2 100644 --- a/static/base.css +++ b/static/base.css @@ -130,6 +130,23 @@ nav img { white-space: pre-wrap; } +/* Task */ + +.task * { + margin: 0; +} + +.task .id { + color: #380; + font-weight: bold; +} + +.task dl { + display: grid; + grid: auto-flow / min-content 1fr; + column-gap: 1ch; +} + /* Queue */ .queue td:nth-child(2), diff --git a/templates/queue_id.html b/templates/queue_id.html new file mode 100644 index 0000000..06cae4f --- /dev/null +++ b/templates/queue_id.html @@ -0,0 +1,42 @@ +{% extends "base.html" %} + +{% block title %}{{ summary }}{% endblock %} + +{% macro r_class(reachable) %} +{%- if reachable == 0 -%} +orphaned +{%- else if reachable == 1 -%} +reachable +{%- else -%} +tracked +{%- endif -%} +{% endmacro %} + +{% macro r_title(reachable) %} +{%- if reachable == 0 -%} +This commit is orphaned. It can't be reached from any ref. +{%- else if reachable == 1 -%} +This commit can only be reached from untracked refs. +{%- else -%} +This commit can be reached from a tracked ref. +{%- endif -%} +{% endmacro %} + +{% block body %} +

Task

+
+ task {{ id }} +
+
Created:
+
{{ date }}
+ +
Priority:
+
{{ priority }}
+ +
Commit:
+
+ {{ short }} +
+
+
+{% endblock %}