rename received_document_ids to matched_documents in the DocumentDeletion task type (reimplementation of #2826)

This commit is contained in:
Irevoire 2022-10-25 11:02:26 +02:00 committed by Clément Renault
parent 7ed3f00b1e
commit 0aca5e84b9
No known key found for this signature in database
GPG Key ID: 92ADA4E935E71FA4
6 changed files with 22 additions and 41 deletions

View File

@ -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 } => {

View File

@ -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)),
});
}

View File

@ -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 } => {

View File

@ -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);

View File

@ -122,7 +122,10 @@ impl From<Details> 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()

View File

@ -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<u64>,
},
SettingsUpdate {
settings: Box<Settings<Unchecked>>,
},
IndexInfo {
primary_key: Option<String>,
},
DocumentDeletion {
received_document_ids: usize,
// TODO why is this optional?
deleted_documents: Option<u64>,
},
ClearAll {
deleted_documents: Option<u64>,
},
TaskCancelation {
matched_tasks: u64,
canceled_tasks: Option<u64>,
original_query: String,
},
TaskDeletion {
matched_tasks: u64,
deleted_tasks: Option<u64>,
original_query: String,
},
Dump {
dump_uid: String,
},
DocumentAdditionOrUpdate { received_documents: u64, indexed_documents: Option<u64> },
SettingsUpdate { settings: Box<Settings<Unchecked>> },
IndexInfo { primary_key: Option<String> },
DocumentDeletion { matched_documents: usize, deleted_documents: Option<u64> },
ClearAll { deleted_documents: Option<u64> },
TaskCancelation { matched_tasks: u64, canceled_tasks: Option<u64>, original_query: String },
TaskDeletion { matched_tasks: u64, deleted_tasks: Option<u64>, 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