Add button to batch-queue commits without runs
This commit is contained in:
parent
238ce5e463
commit
af11d54d0c
7 changed files with 90 additions and 14 deletions
12
.sqlx/query-ee811ca799590d80f1c76a8625ab22c584e528b4dac6ee1103c071eb29282f17.json
generated
Normal file
12
.sqlx/query-ee811ca799590d80f1c76a8625ab22c584e528b4dac6ee1103c071eb29282f17.json
generated
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
{
|
||||||
|
"db_name": "SQLite",
|
||||||
|
"query": "INSERT OR IGNORE INTO queue (hash, date, priority) SELECT hash, ?, ? FROM commits LEFT JOIN runs USING (hash) WHERE reachable = 2 AND id IS NULL ORDER BY unixepoch(committer_date) DESC LIMIT ? ",
|
||||||
|
"describe": {
|
||||||
|
"columns": [],
|
||||||
|
"parameters": {
|
||||||
|
"Right": 3
|
||||||
|
},
|
||||||
|
"nullable": []
|
||||||
|
},
|
||||||
|
"hash": "ee811ca799590d80f1c76a8625ab22c584e528b4dac6ee1103c071eb29282f17"
|
||||||
|
}
|
||||||
|
|
@ -14,8 +14,8 @@ use crate::somehow;
|
||||||
use self::{
|
use self::{
|
||||||
admin::{
|
admin::{
|
||||||
queue::{
|
queue::{
|
||||||
post_admin_queue_add, post_admin_queue_decrease, post_admin_queue_delete,
|
post_admin_queue_add, post_admin_queue_add_batch, post_admin_queue_decrease,
|
||||||
post_admin_queue_increase,
|
post_admin_queue_delete, post_admin_queue_increase,
|
||||||
},
|
},
|
||||||
repo::post_admin_repo_update,
|
repo::post_admin_repo_update,
|
||||||
},
|
},
|
||||||
|
|
@ -55,6 +55,7 @@ pub async fn run(server: Server) -> somehow::Result<()> {
|
||||||
.typed_get(get_run_by_id)
|
.typed_get(get_run_by_id)
|
||||||
.typed_get(get_worker_by_name)
|
.typed_get(get_worker_by_name)
|
||||||
.typed_post(post_admin_queue_add)
|
.typed_post(post_admin_queue_add)
|
||||||
|
.typed_post(post_admin_queue_add_batch)
|
||||||
.typed_post(post_admin_queue_decrease)
|
.typed_post(post_admin_queue_decrease)
|
||||||
.typed_post(post_admin_queue_delete)
|
.typed_post(post_admin_queue_delete)
|
||||||
.typed_post(post_admin_queue_increase)
|
.typed_post(post_admin_queue_increase)
|
||||||
|
|
|
||||||
|
|
@ -13,8 +13,8 @@ use crate::{
|
||||||
server::web::{
|
server::web::{
|
||||||
base::Base,
|
base::Base,
|
||||||
paths::{
|
paths::{
|
||||||
PathAdminQueueAdd, PathAdminQueueDecrease, PathAdminQueueDelete,
|
PathAdminQueueAdd, PathAdminQueueAddBatch, PathAdminQueueDecrease,
|
||||||
PathAdminQueueIncrease, PathQueue,
|
PathAdminQueueDelete, PathAdminQueueIncrease, PathQueue,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
somehow,
|
somehow,
|
||||||
|
|
@ -56,6 +56,49 @@ pub async fn post_admin_queue_add(
|
||||||
Ok(Redirect::to(&format!("{link}")))
|
Ok(Redirect::to(&format!("{link}")))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Deserialize)]
|
||||||
|
pub struct FormAdminQueueAddBatch {
|
||||||
|
amount: u32,
|
||||||
|
#[serde(default)]
|
||||||
|
priority: i32,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn post_admin_queue_add_batch(
|
||||||
|
_path: PathAdminQueueAddBatch,
|
||||||
|
State(config): State<&'static ServerConfig>,
|
||||||
|
State(db): State<SqlitePool>,
|
||||||
|
Form(form): Form<FormAdminQueueAddBatch>,
|
||||||
|
) -> somehow::Result<impl IntoResponse> {
|
||||||
|
let date = OffsetDateTime::now_utc();
|
||||||
|
let added = sqlx::query!(
|
||||||
|
"\
|
||||||
|
INSERT OR IGNORE INTO queue (hash, date, priority) \
|
||||||
|
SELECT hash, ?, ? \
|
||||||
|
FROM commits \
|
||||||
|
LEFT JOIN runs USING (hash) \
|
||||||
|
WHERE reachable = 2 AND id IS NULL \
|
||||||
|
ORDER BY unixepoch(committer_date) DESC \
|
||||||
|
LIMIT ? \
|
||||||
|
",
|
||||||
|
date,
|
||||||
|
form.priority,
|
||||||
|
form.amount,
|
||||||
|
)
|
||||||
|
.execute(&db)
|
||||||
|
.await?
|
||||||
|
.rows_affected();
|
||||||
|
|
||||||
|
if added > 0 {
|
||||||
|
info!(
|
||||||
|
"Admin batch-added {added} commits to queue with priority {}",
|
||||||
|
form.priority,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
let link = Base::link_with_config(config, PathQueue {});
|
||||||
|
Ok(Redirect::to(&format!("{link}")))
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Deserialize)]
|
#[derive(Deserialize)]
|
||||||
pub struct FormAdminQueueDelete {
|
pub struct FormAdminQueueDelete {
|
||||||
hash: String,
|
hash: String,
|
||||||
|
|
|
||||||
|
|
@ -20,8 +20,8 @@ use crate::{
|
||||||
base::{Base, Link, Tab},
|
base::{Base, Link, Tab},
|
||||||
link::{LinkCommit, LinkRunShort, LinkWorker},
|
link::{LinkCommit, LinkRunShort, LinkWorker},
|
||||||
paths::{
|
paths::{
|
||||||
PathAdminQueueDecrease, PathAdminQueueDelete, PathAdminQueueIncrease, PathQueue,
|
PathAdminQueueAddBatch, PathAdminQueueDecrease, PathAdminQueueDelete,
|
||||||
PathQueueDelete, PathQueueInner,
|
PathAdminQueueIncrease, PathQueue, PathQueueDelete, PathQueueInner,
|
||||||
},
|
},
|
||||||
r#static::QUEUE_JS,
|
r#static::QUEUE_JS,
|
||||||
},
|
},
|
||||||
|
|
@ -155,6 +155,7 @@ async fn get_queue_data(
|
||||||
#[derive(Template)]
|
#[derive(Template)]
|
||||||
#[template(path = "pages/queue_inner.html")]
|
#[template(path = "pages/queue_inner.html")]
|
||||||
struct PageInner {
|
struct PageInner {
|
||||||
|
link_admin_queue_add_batch: Link,
|
||||||
workers: Vec<Worker>,
|
workers: Vec<Worker>,
|
||||||
tasks: Vec<Task>,
|
tasks: Vec<Task>,
|
||||||
}
|
}
|
||||||
|
|
@ -167,9 +168,11 @@ pub async fn get_queue_inner(
|
||||||
) -> somehow::Result<impl IntoResponse> {
|
) -> somehow::Result<impl IntoResponse> {
|
||||||
let base = Base::new(config, Tab::Queue);
|
let base = Base::new(config, Tab::Queue);
|
||||||
let sorted_workers = sorted_workers(&workers);
|
let sorted_workers = sorted_workers(&workers);
|
||||||
let workers = get_workers(&db, &sorted_workers, &base).await?;
|
Ok(PageInner {
|
||||||
let tasks = get_queue_data(&db, &sorted_workers, &base).await?;
|
link_admin_queue_add_batch: base.link(PathAdminQueueAddBatch {}),
|
||||||
Ok(PageInner { workers, tasks })
|
workers: get_workers(&db, &sorted_workers, &base).await?,
|
||||||
|
tasks: get_queue_data(&db, &sorted_workers, &base).await?,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Template)]
|
#[derive(Template)]
|
||||||
|
|
@ -188,12 +191,14 @@ pub async fn get_queue(
|
||||||
) -> somehow::Result<impl IntoResponse> {
|
) -> somehow::Result<impl IntoResponse> {
|
||||||
let base = Base::new(config, Tab::Queue);
|
let base = Base::new(config, Tab::Queue);
|
||||||
let sorted_workers = sorted_workers(&workers);
|
let sorted_workers = sorted_workers(&workers);
|
||||||
let workers = get_workers(&db, &sorted_workers, &base).await?;
|
|
||||||
let tasks = get_queue_data(&db, &sorted_workers, &base).await?;
|
|
||||||
Ok(Page {
|
Ok(Page {
|
||||||
link_queue_js: base.link(QUEUE_JS),
|
link_queue_js: base.link(QUEUE_JS),
|
||||||
|
inner: PageInner {
|
||||||
|
link_admin_queue_add_batch: base.link(PathAdminQueueAddBatch {}),
|
||||||
|
workers: get_workers(&db, &sorted_workers, &base).await?,
|
||||||
|
tasks: get_queue_data(&db, &sorted_workers, &base).await?,
|
||||||
|
},
|
||||||
base,
|
base,
|
||||||
inner: PageInner { workers, tasks },
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -61,6 +61,10 @@ pub struct PathAdminRepoUpdate {}
|
||||||
#[typed_path("/admin/queue/add")]
|
#[typed_path("/admin/queue/add")]
|
||||||
pub struct PathAdminQueueAdd {}
|
pub struct PathAdminQueueAdd {}
|
||||||
|
|
||||||
|
#[derive(Deserialize, TypedPath)]
|
||||||
|
#[typed_path("/admin/queue/add_batch")]
|
||||||
|
pub struct PathAdminQueueAddBatch {}
|
||||||
|
|
||||||
#[derive(Deserialize, TypedPath)]
|
#[derive(Deserialize, TypedPath)]
|
||||||
#[typed_path("/admin/queue/delete")]
|
#[typed_path("/admin/queue/delete")]
|
||||||
pub struct PathAdminQueueDelete {}
|
pub struct PathAdminQueueDelete {}
|
||||||
|
|
|
||||||
|
|
@ -52,7 +52,7 @@ There aren't any runs yet.
|
||||||
<input type="hidden" name="hash" value="{{ hash }}">
|
<input type="hidden" name="hash" value="{{ hash }}">
|
||||||
<button>Add to queue</button>
|
<button>Add to queue</button>
|
||||||
with a <label for="priority">priority</label> of
|
with a <label for="priority">priority</label> of
|
||||||
<input id="priority" name="priority" type="number" value="10" min="-2147483648" max="2147483647">.
|
<input type="number" id="priority" name="priority" value="10" min="-2147483648" max="2147483647">.
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
|
||||||
|
|
@ -66,5 +66,16 @@
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
|
<form method="post" action="{{ link_admin_queue_add_batch }}">
|
||||||
|
<label>
|
||||||
|
Batch size:
|
||||||
|
<input type="number" name="amount" value="10" min="1">
|
||||||
|
</label>
|
||||||
|
<label>
|
||||||
|
Priority:
|
||||||
|
<input type="number" id="priority" name="priority" value="-1" min="-2147483648" max="2147483647">
|
||||||
|
</label>
|
||||||
|
<button>Add batch to queue</button>
|
||||||
|
</form>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue