Only mark the first clear document with the amount of cleared documents

This commit is contained in:
Kerollmops 2022-10-05 16:54:06 +02:00 committed by Clément Renault
parent b24b13b036
commit a083c9e452
No known key found for this signature in database
GPG Key ID: 92ADA4E935E71FA4

View File

@ -498,12 +498,19 @@ impl IndexScheduler {
IndexOperation::DocumentClear { mut tasks, .. } => { IndexOperation::DocumentClear { mut tasks, .. } => {
let count = milli::update::ClearDocuments::new(index_wtxn, index).execute()?; let count = milli::update::ClearDocuments::new(index_wtxn, index).execute()?;
let mut first_clear_found = false;
for task in &mut tasks { for task in &mut tasks {
task.status = Status::Succeeded; task.status = Status::Succeeded;
// The first document clear will effectively delete every documents
// in the database but the next ones will clear 0 documents.
task.details = match &task.kind { task.details = match &task.kind {
KindWithContent::DocumentClear { .. } => Some(Details::ClearAll { KindWithContent::DocumentClear { .. } => {
let count = if first_clear_found { 0 } else { count };
first_clear_found = true;
Some(Details::ClearAll {
deleted_documents: Some(count), deleted_documents: Some(count),
}), })
}
otherwise => otherwise.default_details(), otherwise => otherwise.default_details(),
}; };
} }