From 0aca5e84b9de7280ba0d8bc90b2b81387376425a Mon Sep 17 00:00:00 2001 From: Irevoire Date: Tue, 25 Oct 2022 11:02:26 +0200 Subject: [PATCH] rename received_document_ids to matched_documents in the DocumentDeletion task type (reimplementation of #2826) --- dump/src/reader/compat/v5_to_v6.rs | 2 +- index-scheduler/src/batch.rs | 2 +- index-scheduler/src/snapshot.rs | 2 +- index-scheduler/src/utils.rs | 5 ++- meilisearch-http/src/routes/tasks.rs | 5 ++- meilisearch-types/src/tasks.rs | 47 +++++++--------------------- 6 files changed, 22 insertions(+), 41 deletions(-) diff --git a/dump/src/reader/compat/v5_to_v6.rs b/dump/src/reader/compat/v5_to_v6.rs index cfc390960..5d01f0c47 100644 --- a/dump/src/reader/compat/v5_to_v6.rs +++ b/dump/src/reader/compat/v5_to_v6.rs @@ -143,7 +143,7 @@ impl CompatV5ToV6 { received_document_ids, deleted_documents, } => v6::Details::DocumentDeletion { - received_document_ids, + matched_documents: received_document_ids, deleted_documents, }, v5::Details::ClearAll { deleted_documents } => { diff --git a/index-scheduler/src/batch.rs b/index-scheduler/src/batch.rs index c1e41c552..20b6c7e1d 100644 --- a/index-scheduler/src/batch.rs +++ b/index-scheduler/src/batch.rs @@ -928,7 +928,7 @@ impl IndexScheduler { for (task, documents) in tasks.iter_mut().zip(documents) { task.status = Status::Succeeded; task.details = Some(Details::DocumentDeletion { - received_document_ids: documents.len(), + matched_documents: documents.len(), deleted_documents: Some(deleted_documents.min(documents.len() as u64)), }); } diff --git a/index-scheduler/src/snapshot.rs b/index-scheduler/src/snapshot.rs index 902a3b18f..baab8277a 100644 --- a/index-scheduler/src/snapshot.rs +++ b/index-scheduler/src/snapshot.rs @@ -164,7 +164,7 @@ fn snaphsot_details(d: &Details) -> String { format!("{{ primary_key: {primary_key:?} }}") } Details::DocumentDeletion { - received_document_ids, + matched_documents: received_document_ids, deleted_documents, } => format!("{{ received_document_ids: {received_document_ids}, deleted_documents: {deleted_documents:?} }}"), Details::ClearAll { deleted_documents } => { diff --git a/index-scheduler/src/utils.rs b/index-scheduler/src/utils.rs index e22e6157e..432cdd80b 100644 --- a/index-scheduler/src/utils.rs +++ b/index-scheduler/src/utils.rs @@ -373,7 +373,10 @@ impl IndexScheduler { } _ => panic!(), }, - Details::DocumentDeletion { received_document_ids, deleted_documents } => { + Details::DocumentDeletion { + matched_documents: received_document_ids, + deleted_documents, + } => { if let Some(deleted_documents) = deleted_documents { assert_eq!(status, Status::Succeeded); assert!(deleted_documents <= received_document_ids as u64); diff --git a/meilisearch-http/src/routes/tasks.rs b/meilisearch-http/src/routes/tasks.rs index e64776dfb..85f833c36 100644 --- a/meilisearch-http/src/routes/tasks.rs +++ b/meilisearch-http/src/routes/tasks.rs @@ -122,7 +122,10 @@ impl From
for DetailsView { Details::IndexInfo { primary_key } => { DetailsView { primary_key: Some(primary_key), ..DetailsView::default() } } - Details::DocumentDeletion { received_document_ids, deleted_documents } => DetailsView { + Details::DocumentDeletion { + matched_documents: received_document_ids, + deleted_documents, + } => DetailsView { received_document_ids: Some(received_document_ids), deleted_documents: Some(deleted_documents), ..DetailsView::default() diff --git a/meilisearch-types/src/tasks.rs b/meilisearch-types/src/tasks.rs index af23f8171..087980a11 100644 --- a/meilisearch-types/src/tasks.rs +++ b/meilisearch-types/src/tasks.rs @@ -189,7 +189,7 @@ impl KindWithContent { } KindWithContent::DocumentDeletion { index_uid: _, documents_ids } => { Some(Details::DocumentDeletion { - received_document_ids: documents_ids.len(), + matched_documents: documents_ids.len(), deleted_documents: None, }) } @@ -232,7 +232,7 @@ impl KindWithContent { } KindWithContent::DocumentDeletion { index_uid: _, documents_ids } => { Some(Details::DocumentDeletion { - received_document_ids: documents_ids.len(), + matched_documents: documents_ids.len(), deleted_documents: Some(0), }) } @@ -418,41 +418,16 @@ impl FromStr for Kind { #[derive(Debug, PartialEq, Clone, Serialize, Deserialize)] pub enum Details { - DocumentAdditionOrUpdate { - received_documents: u64, - indexed_documents: Option, - }, - SettingsUpdate { - settings: Box>, - }, - IndexInfo { - primary_key: Option, - }, - DocumentDeletion { - received_document_ids: usize, - // TODO why is this optional? - deleted_documents: Option, - }, - ClearAll { - deleted_documents: Option, - }, - TaskCancelation { - matched_tasks: u64, - canceled_tasks: Option, - original_query: String, - }, - TaskDeletion { - matched_tasks: u64, - deleted_tasks: Option, - original_query: String, - }, - Dump { - dump_uid: String, - }, + DocumentAdditionOrUpdate { received_documents: u64, indexed_documents: Option }, + SettingsUpdate { settings: Box> }, + IndexInfo { primary_key: Option }, + DocumentDeletion { matched_documents: usize, deleted_documents: Option }, + ClearAll { deleted_documents: Option }, + TaskCancelation { matched_tasks: u64, canceled_tasks: Option, original_query: String }, + TaskDeletion { matched_tasks: u64, deleted_tasks: Option, original_query: String }, + Dump { dump_uid: String }, // TODO: Lo: Revisit this variant once we have decided on what the POST payload of swapping indexes should be - IndexSwap { - swaps: Vec<(String, String)>, - }, + IndexSwap { swaps: Vec<(String, String)> }, } /// Serialize a `time::Duration` as a best effort ISO 8601 while waiting for