Show individual tasks
This commit is contained in:
parent
171505d7ec
commit
2b81d497bc
5 changed files with 176 additions and 0 deletions
50
.sqlx/query-d9514b13cf1c28edb9d868a25d23e39d60676116f7ca6488032f8cfbf274f320.json
generated
Normal file
50
.sqlx/query-d9514b13cf1c28edb9d868a25d23e39d60676116f7ca6488032f8cfbf274f320.json
generated
Normal file
|
|
@ -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"
|
||||||
|
}
|
||||||
|
|
@ -2,6 +2,7 @@ mod commit;
|
||||||
mod commit_hash;
|
mod commit_hash;
|
||||||
mod index;
|
mod index;
|
||||||
mod queue;
|
mod queue;
|
||||||
|
mod queue_id;
|
||||||
mod r#static;
|
mod r#static;
|
||||||
|
|
||||||
use axum::{routing::get, Router, Server};
|
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("/commit/:hash", get(commit_hash::get))
|
||||||
.route("/queue/", get(queue::get))
|
.route("/queue/", get(queue::get))
|
||||||
.route("/queue/table", get(queue::get_table))
|
.route("/queue/table", get(queue::get_table))
|
||||||
|
.route("/queue/:id", get(queue_id::get))
|
||||||
.fallback(get(r#static::static_handler))
|
.fallback(get(r#static::static_handler))
|
||||||
.with_state(state.clone());
|
.with_state(state.clone());
|
||||||
|
|
||||||
|
|
|
||||||
65
src/web/queue_id.rs
Normal file
65
src/web/queue_id.rs
Normal file
|
|
@ -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<String>,
|
||||||
|
State(config): State<&'static Config>,
|
||||||
|
State(db): State<SqlitePool>,
|
||||||
|
) -> somehow::Result<Response> {
|
||||||
|
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())
|
||||||
|
}
|
||||||
|
|
@ -130,6 +130,23 @@ nav img {
|
||||||
white-space: pre-wrap;
|
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 */
|
||||||
|
|
||||||
.queue td:nth-child(2),
|
.queue td:nth-child(2),
|
||||||
|
|
|
||||||
42
templates/queue_id.html
Normal file
42
templates/queue_id.html
Normal file
|
|
@ -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 %}
|
||||||
|
<h2>Task</h2>
|
||||||
|
<div class="task">
|
||||||
|
<span class="id">task {{ id }}</span>
|
||||||
|
<dl>
|
||||||
|
<dt>Created:</dt>
|
||||||
|
<dd>{{ date }}</dd>
|
||||||
|
|
||||||
|
<dt>Priority:</dt>
|
||||||
|
<dd>{{ priority }}</dd>
|
||||||
|
|
||||||
|
<dt class="{% call r_class(reachable) %}" title="{% call r_title(reachable) %}">Commit:</dt>
|
||||||
|
<dd class="{% call r_class(reachable) %}" title="{% call r_title(reachable) %}">
|
||||||
|
<a href="{{ base.root }}/commit/{{ hash }}">{{ short }}</a>
|
||||||
|
</dd>
|
||||||
|
</dl>
|
||||||
|
</div>
|
||||||
|
{% endblock %}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue