mirror of
https://github.com/meilisearch/MeiliSearch
synced 2025-07-04 20:37:15 +02:00
Expose lastUpdate and isIndexing in /stats endpoint
This commit is contained in:
parent
28404d56b7
commit
6d4981ec25
3 changed files with 37 additions and 0 deletions
|
@ -794,6 +794,12 @@ impl IndexScheduler {
|
|||
Ok(res)
|
||||
}
|
||||
|
||||
// Return true if there is at least one task that is processing.
|
||||
pub fn is_task_processing(&self) -> Result<bool> {
|
||||
let processing_tasks = self.processing_tasks.read().unwrap().processing.len();
|
||||
Ok(processing_tasks > 0)
|
||||
}
|
||||
|
||||
/// Return true iff there is at least one task associated with this index
|
||||
/// that is processing.
|
||||
pub fn is_index_processing(&self, index: &str) -> Result<bool> {
|
||||
|
@ -1808,6 +1814,24 @@ mod tests {
|
|||
snapshot!(snapshot_index_scheduler(&index_scheduler), name: "registered_the_third_task");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_task_is_processing() {
|
||||
let (index_scheduler, mut handle) = IndexScheduler::test(true, vec![]);
|
||||
|
||||
let (file0, documents_count0) = sample_documents(&index_scheduler, 0, 0);
|
||||
file0.persist().unwrap();
|
||||
|
||||
let _ = index_scheduler
|
||||
.register(replace_document_import_task("catto", None, 0, documents_count0))
|
||||
.unwrap();
|
||||
snapshot!(snapshot_index_scheduler(&index_scheduler), name: "registered_a_task");
|
||||
|
||||
handle.advance_till([Start, BatchCreated, InsideProcessBatch]);
|
||||
snapshot!(snapshot_index_scheduler(&index_scheduler), name: "initial_task_processing");
|
||||
|
||||
assert_eq!(index_scheduler.is_task_processing().unwrap(), true);
|
||||
}
|
||||
|
||||
/// We send a lot of tasks but notify the tasks scheduler only once as
|
||||
/// we send them very fast, we must make sure that they are all processed.
|
||||
#[test]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue