Identify queue items by commit hash, not id
This commit is contained in:
parent
bf08d00922
commit
e5de9ccb97
11 changed files with 42 additions and 186 deletions
|
|
@ -1,12 +0,0 @@
|
||||||
{
|
|
||||||
"db_name": "SQLite",
|
|
||||||
"query": "INSERT INTO queue (id, hash, date) VALUES (?, ?, ?)",
|
|
||||||
"describe": {
|
|
||||||
"columns": [],
|
|
||||||
"parameters": {
|
|
||||||
"Right": 3
|
|
||||||
},
|
|
||||||
"nullable": []
|
|
||||||
},
|
|
||||||
"hash": "09d6281af1344afb2d6265149d4026e72badc3e18bc53a03e6b78011ee270ee1"
|
|
||||||
}
|
|
||||||
|
|
@ -1,50 +1,44 @@
|
||||||
{
|
{
|
||||||
"db_name": "SQLite",
|
"db_name": "SQLite",
|
||||||
"query": "SELECT id, hash, date AS \"date: time::OffsetDateTime\", priority, message, reachable FROM queue JOIN commits USING (hash) WHERE id = ? ",
|
"query": "SELECT hash, message, reachable, date AS \"date: time::OffsetDateTime\", priority FROM queue JOIN commits USING (hash) ORDER BY priority DESC, unixepoch(date) DESC, hash ASC ",
|
||||||
"describe": {
|
"describe": {
|
||||||
"columns": [
|
"columns": [
|
||||||
{
|
{
|
||||||
"name": "id",
|
"name": "hash",
|
||||||
"ordinal": 0,
|
"ordinal": 0,
|
||||||
"type_info": "Text"
|
"type_info": "Text"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "hash",
|
"name": "message",
|
||||||
"ordinal": 1,
|
"ordinal": 1,
|
||||||
"type_info": "Text"
|
"type_info": "Text"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "date: time::OffsetDateTime",
|
"name": "reachable",
|
||||||
"ordinal": 2,
|
"ordinal": 2,
|
||||||
|
"type_info": "Int64"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "date: time::OffsetDateTime",
|
||||||
|
"ordinal": 3,
|
||||||
"type_info": "Text"
|
"type_info": "Text"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "priority",
|
"name": "priority",
|
||||||
"ordinal": 3,
|
|
||||||
"type_info": "Int64"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "message",
|
|
||||||
"ordinal": 4,
|
"ordinal": 4,
|
||||||
"type_info": "Text"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "reachable",
|
|
||||||
"ordinal": 5,
|
|
||||||
"type_info": "Int64"
|
"type_info": "Int64"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"parameters": {
|
"parameters": {
|
||||||
"Right": 1
|
"Right": 0
|
||||||
},
|
},
|
||||||
"nullable": [
|
"nullable": [
|
||||||
false,
|
false,
|
||||||
false,
|
false,
|
||||||
false,
|
false,
|
||||||
false,
|
false,
|
||||||
false,
|
|
||||||
false
|
false
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"hash": "d9514b13cf1c28edb9d868a25d23e39d60676116f7ca6488032f8cfbf274f320"
|
"hash": "6c9e27efd2c88772bbf1f89bf53d0abb49cd82788b1e88e4e2ef153b0f35a8fb"
|
||||||
}
|
}
|
||||||
|
|
@ -1,50 +0,0 @@
|
||||||
{
|
|
||||||
"db_name": "SQLite",
|
|
||||||
"query": "SELECT id, hash, message, reachable, date AS \"date: time::OffsetDateTime\", priority FROM queue JOIN commits USING (hash) ORDER BY priority DESC, unixepoch(date) DESC, hash ASC ",
|
|
||||||
"describe": {
|
|
||||||
"columns": [
|
|
||||||
{
|
|
||||||
"name": "id",
|
|
||||||
"ordinal": 0,
|
|
||||||
"type_info": "Text"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "hash",
|
|
||||||
"ordinal": 1,
|
|
||||||
"type_info": "Text"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "message",
|
|
||||||
"ordinal": 2,
|
|
||||||
"type_info": "Text"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "reachable",
|
|
||||||
"ordinal": 3,
|
|
||||||
"type_info": "Int64"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "date: time::OffsetDateTime",
|
|
||||||
"ordinal": 4,
|
|
||||||
"type_info": "Text"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "priority",
|
|
||||||
"ordinal": 5,
|
|
||||||
"type_info": "Int64"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"parameters": {
|
|
||||||
"Right": 0
|
|
||||||
},
|
|
||||||
"nullable": [
|
|
||||||
false,
|
|
||||||
false,
|
|
||||||
false,
|
|
||||||
false,
|
|
||||||
false,
|
|
||||||
false
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"hash": "ca4e47d1a7fa0bbe474992eafeca39fa12d022fc171b8e4195cf1899ccb0557b"
|
|
||||||
}
|
|
||||||
12
.sqlx/query-d620ced558e472a5fe22d5ad365cf25726a7bb969acc8b9411a2591ce7bcc92f.json
generated
Normal file
12
.sqlx/query-d620ced558e472a5fe22d5ad365cf25726a7bb969acc8b9411a2591ce7bcc92f.json
generated
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
{
|
||||||
|
"db_name": "SQLite",
|
||||||
|
"query": "INSERT INTO queue (hash, date) VALUES (?, ?)",
|
||||||
|
"describe": {
|
||||||
|
"columns": [],
|
||||||
|
"parameters": {
|
||||||
|
"Right": 2
|
||||||
|
},
|
||||||
|
"nullable": []
|
||||||
|
},
|
||||||
|
"hash": "d620ced558e472a5fe22d5ad365cf25726a7bb969acc8b9411a2591ce7bcc92f"
|
||||||
|
}
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
CREATE TABLE queue (
|
CREATE TABLE queue (
|
||||||
id TEXT NOT NULL PRIMARY KEY,
|
hash TEXT NOT NULL PRIMARY KEY,
|
||||||
hash TEXT NOT NULL,
|
|
||||||
date TEXT NOT NULL,
|
date TEXT NOT NULL,
|
||||||
priority INT NOT NULL DEFAULT 0,
|
priority INT NOT NULL DEFAULT 0,
|
||||||
FOREIGN KEY (hash) REFERENCES commits (hash) ON DELETE CASCADE
|
FOREIGN KEY (hash) REFERENCES commits (hash) ON DELETE CASCADE
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ use sqlx::{Acquire, SqlitePool};
|
||||||
use time::OffsetDateTime;
|
use time::OffsetDateTime;
|
||||||
use tracing::debug;
|
use tracing::debug;
|
||||||
|
|
||||||
use crate::{server::util, somehow};
|
use crate::somehow;
|
||||||
|
|
||||||
pub async fn update(db: &SqlitePool) -> somehow::Result<()> {
|
pub async fn update(db: &SqlitePool) -> somehow::Result<()> {
|
||||||
debug!("Updating queue");
|
debug!("Updating queue");
|
||||||
|
|
@ -17,13 +17,11 @@ pub async fn update(db: &SqlitePool) -> somehow::Result<()> {
|
||||||
|
|
||||||
// Insert them into the queue
|
// Insert them into the queue
|
||||||
for row in new {
|
for row in new {
|
||||||
let id = util::new_run_id();
|
|
||||||
let date = OffsetDateTime::now_utc();
|
let date = OffsetDateTime::now_utc();
|
||||||
sqlx::query!(
|
sqlx::query!(
|
||||||
"INSERT INTO queue (id, hash, date) VALUES (?, ?, ?)",
|
"INSERT INTO queue (hash, date) VALUES (?, ?)",
|
||||||
id,
|
|
||||||
row.hash,
|
row.hash,
|
||||||
date
|
date,
|
||||||
)
|
)
|
||||||
.execute(&mut *conn)
|
.execute(&mut *conn)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@ 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};
|
use axum::{routing::get, Router};
|
||||||
|
|
@ -48,7 +47,6 @@ pub async fn run(server: Server) -> 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(server.clone());
|
.with_state(server.clone());
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ use crate::{config::Config, server::util, somehow};
|
||||||
use super::{Base, Tab};
|
use super::{Base, Tab};
|
||||||
|
|
||||||
struct Task {
|
struct Task {
|
||||||
id: String,
|
hash: String,
|
||||||
short: String,
|
short: String,
|
||||||
reachable: i64,
|
reachable: i64,
|
||||||
since: String,
|
since: String,
|
||||||
|
|
@ -20,7 +20,6 @@ async fn get_queue(db: &SqlitePool) -> somehow::Result<Vec<Task>> {
|
||||||
let mut tasks = sqlx::query!(
|
let mut tasks = sqlx::query!(
|
||||||
"\
|
"\
|
||||||
SELECT \
|
SELECT \
|
||||||
id, \
|
|
||||||
hash, \
|
hash, \
|
||||||
message, \
|
message, \
|
||||||
reachable, \
|
reachable, \
|
||||||
|
|
@ -33,8 +32,8 @@ async fn get_queue(db: &SqlitePool) -> somehow::Result<Vec<Task>> {
|
||||||
)
|
)
|
||||||
.fetch(db)
|
.fetch(db)
|
||||||
.map_ok(|r| Task {
|
.map_ok(|r| Task {
|
||||||
id: r.id,
|
|
||||||
short: util::format_commit_short(&r.hash, &r.message),
|
short: util::format_commit_short(&r.hash, &r.message),
|
||||||
|
hash: r.hash,
|
||||||
reachable: r.reachable,
|
reachable: r.reachable,
|
||||||
since: util::format_delta_from_now(r.date),
|
since: util::format_delta_from_now(r.date),
|
||||||
priority: r.priority,
|
priority: r.priority,
|
||||||
|
|
@ -59,12 +58,19 @@ async fn get_queue(db: &SqlitePool) -> somehow::Result<Vec<Task>> {
|
||||||
#[derive(Template)]
|
#[derive(Template)]
|
||||||
#[template(path = "queue_table.html")]
|
#[template(path = "queue_table.html")]
|
||||||
struct QueueTableTemplate {
|
struct QueueTableTemplate {
|
||||||
|
base: Base,
|
||||||
tasks: Vec<Task>,
|
tasks: Vec<Task>,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn get_table(State(db): State<SqlitePool>) -> somehow::Result<impl IntoResponse> {
|
pub async fn get_table(
|
||||||
|
State(config): State<&'static Config>,
|
||||||
|
State(db): State<SqlitePool>,
|
||||||
|
) -> somehow::Result<impl IntoResponse> {
|
||||||
let tasks = get_queue(&db).await?;
|
let tasks = get_queue(&db).await?;
|
||||||
Ok(QueueTableTemplate { tasks })
|
Ok(QueueTableTemplate {
|
||||||
|
base: Base::new(config, Tab::Queue),
|
||||||
|
tasks,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
#[derive(Template)]
|
#[derive(Template)]
|
||||||
#[template(path = "queue.html")]
|
#[template(path = "queue.html")]
|
||||||
|
|
@ -77,9 +83,10 @@ pub async fn get(
|
||||||
State(config): State<&'static Config>,
|
State(config): State<&'static Config>,
|
||||||
State(db): State<SqlitePool>,
|
State(db): State<SqlitePool>,
|
||||||
) -> somehow::Result<impl IntoResponse> {
|
) -> somehow::Result<impl IntoResponse> {
|
||||||
|
let base = Base::new(config, Tab::Queue);
|
||||||
let tasks = get_queue(&db).await?;
|
let tasks = get_queue(&db).await?;
|
||||||
Ok(QueueTemplate {
|
Ok(QueueTemplate {
|
||||||
base: Base::new(config, Tab::Queue),
|
base: base.clone(),
|
||||||
table: QueueTableTemplate { tasks },
|
table: QueueTableTemplate { base, tasks },
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,65 +0,0 @@
|
||||||
use askama::Template;
|
|
||||||
use axum::{
|
|
||||||
extract::{Path, State},
|
|
||||||
http::StatusCode,
|
|
||||||
response::{IntoResponse, Response},
|
|
||||||
};
|
|
||||||
use sqlx::SqlitePool;
|
|
||||||
|
|
||||||
use crate::{config::Config, server::util, somehow};
|
|
||||||
|
|
||||||
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())
|
|
||||||
}
|
|
||||||
|
|
@ -1,25 +0,0 @@
|
||||||
{% extends "base.html" %}
|
|
||||||
{% import "util.html" as util %}
|
|
||||||
|
|
||||||
{% block title %}{{ summary }}{% endblock %}
|
|
||||||
|
|
||||||
{% 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>Commit:</dt>
|
|
||||||
<dd>
|
|
||||||
<a href="{{ base.root }}/commit/{{ hash }}">
|
|
||||||
{% call util::commit_short(short, reachable) %}
|
|
||||||
</a>
|
|
||||||
</dd>
|
|
||||||
</dl>
|
|
||||||
</div>
|
|
||||||
{% endblock %}
|
|
||||||
|
|
@ -12,7 +12,7 @@
|
||||||
{% for task in tasks %}
|
{% for task in tasks %}
|
||||||
<tr {% if task.odd %} class="odd" {% endif %}>
|
<tr {% if task.odd %} class="odd" {% endif %}>
|
||||||
<td>
|
<td>
|
||||||
<a href="{{ task.id }}">
|
<a href="{{ base.root }}/commit/{{ task.hash }}">
|
||||||
{% call util::commit_short(task.short, task.reachable) %}
|
{% call util::commit_short(task.short, task.reachable) %}
|
||||||
</a>
|
</a>
|
||||||
</td>
|
</td>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue