Patch the delete and cancel tasks routes

This commit is contained in:
Kerollmops 2022-10-26 11:11:53 +02:00 committed by Clément Renault
parent 6db90ba6cc
commit c641888a23
No known key found for this signature in database
GPG Key ID: 92ADA4E935E71FA4
2 changed files with 6 additions and 6 deletions

View File

@ -31,7 +31,7 @@ pub fn configure(cfg: &mut web::ServiceConfig) {
.service(web::resource("/stats").route(web::get().to(get_stats)))
.service(web::resource("/version").route(web::get().to(get_version)))
.service(web::scope("/indexes").configure(indexes::configure))
.service(web::scope("swap-indexes").configure(swap_indexes::configure));
.service(web::scope("/swap-indexes").configure(swap_indexes::configure));
}
/// Extracts the raw values from the `StarOr` types and

View File

@ -10,7 +10,7 @@ use serde::{Deserialize, Serialize};
use serde_cs::vec::CS;
use serde_json::json;
use time::{Duration, OffsetDateTime};
use tokio::task::block_in_place;
use tokio::task;
use super::fold_star_or;
use crate::analytics::Analytics;
@ -26,8 +26,8 @@ pub fn configure(cfg: &mut web::ServiceConfig) {
.route(web::get().to(SeqHandler(get_tasks)))
.route(web::delete().to(SeqHandler(delete_tasks))),
)
.service(web::resource("/{task_id}").route(web::get().to(SeqHandler(get_task))))
.service(web::resource("/cancel").route(web::post().to(SeqHandler(cancel_tasks))));
.service(web::resource("/cancel").route(web::post().to(SeqHandler(cancel_tasks))))
.service(web::resource("/{task_id}").route(web::get().to(SeqHandler(get_task))));
}
#[derive(Debug, Clone, PartialEq, Serialize)]
@ -294,7 +294,7 @@ async fn cancel_tasks(
let task_cancelation =
KindWithContent::TaskCancelation { query: req.query_string().to_string(), tasks };
let task = block_in_place(|| index_scheduler.register(task_cancelation))?;
let task = task::spawn_blocking(move || index_scheduler.register(task_cancelation)).await??;
let task_view = TaskView::from_task(&task);
Ok(HttpResponse::Ok().json(task_view))
@ -351,7 +351,7 @@ async fn delete_tasks(
let task_deletion =
KindWithContent::TaskDeletion { query: req.query_string().to_string(), tasks };
let task = block_in_place(|| index_scheduler.register(task_deletion))?;
let task = task::spawn_blocking(move || index_scheduler.register(task_deletion)).await??;
let task_view = TaskView::from_task(&task);
Ok(HttpResponse::Ok().json(task_view))