From 8a23e707c194a75e56137086dc49512190883547 Mon Sep 17 00:00:00 2001 From: Irevoire Date: Sun, 23 Oct 2022 11:23:24 +0200 Subject: [PATCH] fix the task view and forward the task db size --- index-scheduler/src/lib.rs | 3 +++ meilisearch-http/src/lib.rs | 1 + meilisearch-http/src/routes/tasks.rs | 35 ++++++++++------------------ 3 files changed, 16 insertions(+), 23 deletions(-) diff --git a/index-scheduler/src/lib.rs b/index-scheduler/src/lib.rs index 8df71a2d7..615b18d4e 100644 --- a/index-scheduler/src/lib.rs +++ b/index-scheduler/src/lib.rs @@ -273,6 +273,7 @@ impl IndexScheduler { update_file_path: PathBuf, indexes_path: PathBuf, dumps_path: PathBuf, + task_db_size: usize, index_size: usize, indexer_config: IndexerConfig, autobatching_enabled: bool, @@ -285,6 +286,7 @@ impl IndexScheduler { let mut options = heed::EnvOpenOptions::new(); options.max_dbs(9); + options.map_size(task_db_size); let env = options.open(tasks_path)?; let file_store = FileStore::new(&update_file_path)?; @@ -834,6 +836,7 @@ mod tests { tempdir.path().join("indexes"), tempdir.path().join("dumps"), 1024 * 1024, + 1024 * 1024, IndexerConfig::default(), autobatching, // enable autobatching sender, diff --git a/meilisearch-http/src/lib.rs b/meilisearch-http/src/lib.rs index 2249cb9b7..59a747782 100644 --- a/meilisearch-http/src/lib.rs +++ b/meilisearch-http/src/lib.rs @@ -114,6 +114,7 @@ pub fn setup_meilisearch(opt: &Opt) -> anyhow::Result<(IndexScheduler, AuthContr opt.db_path.join("update_files"), opt.db_path.join("indexes"), opt.dumps_dir.clone(), + opt.max_task_db_size.get_bytes() as usize, opt.max_index_size.get_bytes() as usize, (&opt.indexer_options).try_into()?, true, diff --git a/meilisearch-http/src/routes/tasks.rs b/meilisearch-http/src/routes/tasks.rs index cc7c11341..e64776dfb 100644 --- a/meilisearch-http/src/routes/tasks.rs +++ b/meilisearch-http/src/routes/tasks.rs @@ -48,25 +48,13 @@ pub struct TaskView { #[serde(skip_serializing_if = "Option::is_none")] pub error: Option, - #[serde( - serialize_with = "serialize_duration", - skip_serializing_if = "Option::is_none", - default - )] + #[serde(serialize_with = "serialize_duration", default)] pub duration: Option, #[serde(with = "time::serde::rfc3339")] pub enqueued_at: OffsetDateTime, - #[serde( - with = "time::serde::rfc3339::option", - skip_serializing_if = "Option::is_none", - default - )] + #[serde(with = "time::serde::rfc3339::option", default)] pub started_at: Option, - #[serde( - with = "time::serde::rfc3339::option", - skip_serializing_if = "Option::is_none", - default - )] + #[serde(with = "time::serde::rfc3339::option", default)] pub finished_at: Option, } @@ -366,6 +354,14 @@ async fn delete_tasks( Ok(HttpResponse::Ok().json(task_view)) } +#[derive(Debug, Serialize)] +pub struct AllTasks { + results: Vec, + limit: u32, + from: Option, + next: Option, +} + async fn get_tasks( index_scheduler: GuardedData, Data>, params: web::Query, @@ -439,14 +435,7 @@ async fn get_tasks( let from = tasks_results.first().map(|t| t.uid); - // TODO: TAMO: define a structure to represent this type - let tasks = json!({ - "results": tasks_results, - "limit": limit.saturating_sub(1), - "from": from, - "next": next, - }); - + let tasks = AllTasks { results: tasks_results, limit: limit.saturating_sub(1), from, next }; Ok(HttpResponse::Ok().json(tasks)) }