Add "Enqueue" button to commits
This commit is contained in:
parent
5e0b8e3c8c
commit
48693d3f1c
4 changed files with 41 additions and 3 deletions
12
.sqlx/query-091ccc5f03da1f11d8efafe1a0082e62f7973dc2d35835693dd5bdd696759de0.json
generated
Normal file
12
.sqlx/query-091ccc5f03da1f11d8efafe1a0082e62f7973dc2d35835693dd5bdd696759de0.json
generated
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"db_name": "SQLite",
|
||||
"query": "INSERT OR IGNORE INTO queue (hash, date, priority) VALUES (?, ?, 1)",
|
||||
"describe": {
|
||||
"columns": [],
|
||||
"parameters": {
|
||||
"Right": 2
|
||||
},
|
||||
"nullable": []
|
||||
},
|
||||
"hash": "091ccc5f03da1f11d8efafe1a0082e62f7973dc2d35835693dd5bdd696759de0"
|
||||
}
|
||||
|
|
@ -6,7 +6,10 @@ mod queue;
|
|||
mod r#static;
|
||||
mod worker;
|
||||
|
||||
use axum::{routing::get, Router};
|
||||
use axum::{
|
||||
routing::{get, post},
|
||||
Router,
|
||||
};
|
||||
|
||||
use crate::{config::Config, somehow};
|
||||
|
||||
|
|
@ -46,9 +49,10 @@ pub async fn run(server: Server) -> somehow::Result<()> {
|
|||
let app = Router::new()
|
||||
.route("/", get(index::get))
|
||||
.route("/commit/:hash", get(commit::get))
|
||||
.route("/worker/:name", get(worker::get))
|
||||
.route("/commit/:hash/enqueue", post(commit::post_enqueue))
|
||||
.route("/queue/", get(queue::get))
|
||||
.route("/queue/inner", get(queue::get_inner))
|
||||
.route("/worker/:name", get(worker::get))
|
||||
.merge(api::router(&server))
|
||||
.fallback(get(r#static::static_handler))
|
||||
.with_state(server.clone());
|
||||
|
|
|
|||
|
|
@ -2,10 +2,11 @@ use askama::Template;
|
|||
use axum::{
|
||||
extract::{Path, State},
|
||||
http::StatusCode,
|
||||
response::{IntoResponse, Response},
|
||||
response::{IntoResponse, Redirect, Response},
|
||||
};
|
||||
use futures::TryStreamExt;
|
||||
use sqlx::SqlitePool;
|
||||
use time::OffsetDateTime;
|
||||
|
||||
use crate::{config::Config, server::util, somehow};
|
||||
|
||||
|
|
@ -98,3 +99,20 @@ pub async fn get(
|
|||
}
|
||||
.into_response())
|
||||
}
|
||||
|
||||
pub async fn post_enqueue(
|
||||
Path(hash): Path<String>,
|
||||
State(config): State<&'static Config>,
|
||||
State(db): State<SqlitePool>,
|
||||
) -> somehow::Result<impl IntoResponse> {
|
||||
let date = OffsetDateTime::now_utc();
|
||||
sqlx::query!(
|
||||
"INSERT OR IGNORE INTO queue (hash, date, priority) VALUES (?, ?, 1)",
|
||||
hash,
|
||||
date,
|
||||
)
|
||||
.execute(&db)
|
||||
.await?;
|
||||
|
||||
Ok(Redirect::to(&format!("{}queue/", config.web_base)))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,4 +33,8 @@
|
|||
<pre class="{% call util::commit_class(reachable) %}"
|
||||
title="{% call util::commit_title(reachable) %}">{{ message }}</pre>
|
||||
</div>
|
||||
|
||||
<form method="post" action="{{ base.root }}commit/{{ hash }}/enqueue">
|
||||
<button>Enqueue</button>
|
||||
</form>
|
||||
{% endblock %}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue