Add "Enqueue" button to commits
This commit is contained in:
parent
5e0b8e3c8c
commit
48693d3f1c
4 changed files with 41 additions and 3 deletions
|
|
@ -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)))
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue