Update the tasks statuses

This commit is contained in:
Kerollmops 2022-10-04 18:50:18 +02:00 committed by Clément Renault
parent 88a0ed9736
commit f3f6bbf624
No known key found for this signature in database
GPG key ID: 92ADA4E935E71FA4
5 changed files with 126 additions and 42 deletions

View file

@ -131,7 +131,7 @@ pub enum KindWithContent {
primary_key: Option<String>,
method: IndexDocumentsMethod,
content_file: Uuid,
documents_count: usize,
documents_count: u64,
allow_index_creation: bool,
},
DocumentDeletion {
@ -255,6 +255,45 @@ impl KindWithContent {
IndexSwap { lhs, rhs } => Some(vec![lhs, rhs]),
}
}
/// Returns the default `Details` that correspond to this `KindWithContent`,
/// `None` if it cannot be generated.
pub fn default_details(&self) -> Option<Details> {
match self {
KindWithContent::DocumentImport {
documents_count, ..
} => Some(Details::DocumentAddition {
received_documents: *documents_count,
indexed_documents: 0,
}),
KindWithContent::DocumentDeletion {
index_uid: _,
documents_ids,
} => Some(Details::DocumentDeletion {
received_document_ids: documents_ids.len(),
deleted_documents: None,
}),
KindWithContent::DocumentClear { .. } => Some(Details::ClearAll {
deleted_documents: None,
}),
KindWithContent::Settings { new_settings, .. } => Some(Details::Settings {
settings: new_settings.clone(),
}),
KindWithContent::IndexDeletion { .. } => Some(Details::IndexInfo { primary_key: None }),
KindWithContent::IndexCreation { primary_key, .. }
| KindWithContent::IndexUpdate { primary_key, .. } => Some(Details::IndexInfo {
primary_key: primary_key.clone(),
}),
KindWithContent::IndexSwap { .. } => {
todo!()
}
KindWithContent::CancelTask { .. } => {
todo!()
}
KindWithContent::DumpExport { .. } => None,
KindWithContent::Snapshot => None,
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]