mirror of
https://github.com/meilisearch/MeiliSearch
synced 2024-11-26 23:04:26 +01:00
deduplicate pending and processing updates
This commit is contained in:
parent
402203aa2a
commit
4552c42f88
@ -103,11 +103,27 @@ impl IndexController for LocalIndexController {
|
||||
fn all_update_status(&self, index: impl AsRef<str>) -> anyhow::Result<Vec<UpdateStatus<UpdateMeta, UpdateResult, String>>> {
|
||||
match self.indexes.index(&index)? {
|
||||
Some((_, update_store)) => {
|
||||
let updates = update_store.iter_metas(|processing, processed, pending, aborted, failed| {
|
||||
let updates = update_store.iter_metas(|processing, processed, aborted, pending, failed| {
|
||||
let processing_id = processing
|
||||
.as_ref()
|
||||
.map(|p| p.id());
|
||||
|
||||
Ok(processing
|
||||
.map(UpdateStatus::from)
|
||||
.into_iter()
|
||||
.chain(pending.filter_map(|p| p.ok()).map(|(_, u)| UpdateStatus::from(u)))
|
||||
.chain(pending.
|
||||
filter_map(|p| p.ok())
|
||||
// if an update is processing, filter out this update from the pending
|
||||
// updates.
|
||||
.filter(|(_, u)| {
|
||||
println!("processing: {:?}", processing_id);
|
||||
processing_id
|
||||
.map(|id| {
|
||||
println!("id: {}, pending: {}", id, u.id());
|
||||
id != u.id()
|
||||
})
|
||||
.unwrap_or(true)})
|
||||
.map(|(_, u)| UpdateStatus::from(u)))
|
||||
.chain(aborted.filter_map(Result::ok).map(|(_, u)| UpdateStatus::from(u)))
|
||||
.chain(processed.filter_map(Result::ok).map(|(_, u)| UpdateStatus::from(u)))
|
||||
.chain(failed.filter_map(Result::ok).map(|(_, u)| UpdateStatus::from(u)))
|
||||
|
Loading…
Reference in New Issue
Block a user