deduplicate pending and processing updates
@@ -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)))
