From 1e694ae432fcc042f301f6bd87d25f420d315b53 Mon Sep 17 00:00:00 2001 From: Tamo Date: Wed, 20 Nov 2024 17:48:26 +0100 Subject: [PATCH] improve the count of the number of tasks in a batch --- crates/index-scheduler/src/utils.rs | 4 ++-- crates/meilisearch/tests/batches/mod.rs | 7 ++++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/crates/index-scheduler/src/utils.rs b/crates/index-scheduler/src/utils.rs index 92e5e4b99..1ca782f8c 100644 --- a/crates/index-scheduler/src/utils.rs +++ b/crates/index-scheduler/src/utils.rs @@ -61,9 +61,9 @@ impl ProcessingBatch { /// Update itself with the content of the task and update the batch id in the task. pub fn processing<'a>(&mut self, tasks: impl IntoIterator) { - self.stats.total_nb_tasks += 1; - for task in tasks.into_iter() { + self.stats.total_nb_tasks += 1; + task.batch_uid = Some(self.uid); // We don't store the statuses in the map since they're all enqueued but we must // still store them in the stats since that can be displayed. diff --git a/crates/meilisearch/tests/batches/mod.rs b/crates/meilisearch/tests/batches/mod.rs index 81d254f9f..799aa3df7 100644 --- a/crates/meilisearch/tests/batches/mod.rs +++ b/crates/meilisearch/tests/batches/mod.rs @@ -46,7 +46,12 @@ async fn list_batches() { .await; let (response, code) = index.list_batches().await; assert_eq!(code, 200); - assert_eq!(response["results"].as_array().unwrap().len(), 2); + assert_eq!( + response["results"].as_array().unwrap().len(), + 2, + "{}", + serde_json::to_string_pretty(&response).unwrap() + ); } #[actix_rt::test]