fix the return of the task cancelation and task deletion

This commit is contained in:
Irevoire 2022-10-27 01:00:56 +02:00 committed by Clément Renault
parent 6280bd51a9
commit 6c2ecec4d0
No known key found for this signature in database
GPG Key ID: 92ADA4E935E71FA4
2 changed files with 5 additions and 6 deletions

View File

@ -12,7 +12,6 @@ use crate::error::MeilisearchHttpError;
use crate::extractors::authentication::policies::*; use crate::extractors::authentication::policies::*;
use crate::extractors::authentication::{AuthenticationError, GuardedData}; use crate::extractors::authentication::{AuthenticationError, GuardedData};
use crate::extractors::sequential_extractor::SeqHandler; use crate::extractors::sequential_extractor::SeqHandler;
use crate::routes::tasks::TaskView;
pub fn configure(cfg: &mut web::ServiceConfig) { pub fn configure(cfg: &mut web::ServiceConfig) {
cfg.service(web::resource("").route(web::post().to(SeqHandler(swap_indexes)))); cfg.service(web::resource("").route(web::post().to(SeqHandler(swap_indexes))));

View File

@ -14,7 +14,7 @@ use serde_json::json;
use time::{Duration, OffsetDateTime}; use time::{Duration, OffsetDateTime};
use tokio::task; use tokio::task;
use super::fold_star_or; use super::{fold_star_or, SummarizedTaskView};
use crate::analytics::Analytics; use crate::analytics::Analytics;
use crate::extractors::authentication::policies::*; use crate::extractors::authentication::policies::*;
use crate::extractors::authentication::GuardedData; use crate::extractors::authentication::GuardedData;
@ -297,9 +297,9 @@ async fn cancel_tasks(
KindWithContent::TaskCancelation { query: req.query_string().to_string(), tasks }; KindWithContent::TaskCancelation { query: req.query_string().to_string(), tasks };
let task = task::spawn_blocking(move || index_scheduler.register(task_cancelation)).await??; let task = task::spawn_blocking(move || index_scheduler.register(task_cancelation)).await??;
let task_view = TaskView::from_task(&task); let task: SummarizedTaskView = task.into();
Ok(HttpResponse::Ok().json(task_view)) Ok(HttpResponse::Ok().json(task))
} }
async fn delete_tasks( async fn delete_tasks(
@ -354,9 +354,9 @@ async fn delete_tasks(
KindWithContent::TaskDeletion { query: req.query_string().to_string(), tasks }; KindWithContent::TaskDeletion { query: req.query_string().to_string(), tasks };
let task = task::spawn_blocking(move || index_scheduler.register(task_deletion)).await??; let task = task::spawn_blocking(move || index_scheduler.register(task_deletion)).await??;
let task_view = TaskView::from_task(&task); let task: SummarizedTaskView = task.into();
Ok(HttpResponse::Ok().json(task_view)) Ok(HttpResponse::Ok().json(task))
} }
#[derive(Debug, Serialize)] #[derive(Debug, Serialize)]