From 6c2ecec4d0fafb69392c63eb16318a83184ea05a Mon Sep 17 00:00:00 2001 From: Irevoire Date: Thu, 27 Oct 2022 01:00:56 +0200 Subject: [PATCH] fix the return of the task cancelation and task deletion --- meilisearch-http/src/routes/swap_indexes.rs | 1 - meilisearch-http/src/routes/tasks.rs | 10 +++++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/meilisearch-http/src/routes/swap_indexes.rs b/meilisearch-http/src/routes/swap_indexes.rs index 5b939e8cc..6389bad58 100644 --- a/meilisearch-http/src/routes/swap_indexes.rs +++ b/meilisearch-http/src/routes/swap_indexes.rs @@ -12,7 +12,6 @@ use crate::error::MeilisearchHttpError; use crate::extractors::authentication::policies::*; use crate::extractors::authentication::{AuthenticationError, GuardedData}; use crate::extractors::sequential_extractor::SeqHandler; -use crate::routes::tasks::TaskView; pub fn configure(cfg: &mut web::ServiceConfig) { cfg.service(web::resource("").route(web::post().to(SeqHandler(swap_indexes)))); diff --git a/meilisearch-http/src/routes/tasks.rs b/meilisearch-http/src/routes/tasks.rs index d4eb1607d..59f1a1f68 100644 --- a/meilisearch-http/src/routes/tasks.rs +++ b/meilisearch-http/src/routes/tasks.rs @@ -14,7 +14,7 @@ use serde_json::json; use time::{Duration, OffsetDateTime}; use tokio::task; -use super::fold_star_or; +use super::{fold_star_or, SummarizedTaskView}; use crate::analytics::Analytics; use crate::extractors::authentication::policies::*; use crate::extractors::authentication::GuardedData; @@ -297,9 +297,9 @@ async fn cancel_tasks( KindWithContent::TaskCancelation { query: req.query_string().to_string(), tasks }; 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( @@ -354,9 +354,9 @@ async fn delete_tasks( KindWithContent::TaskDeletion { query: req.query_string().to_string(), tasks }; 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)]